:heavy_check_mark: test/String/run_length_encode/yukicoder-0203.cpp

Depends on

Code

// competitive-verifier: PROBLEM https://yukicoder.me/problems/no/203

#include "String/run_length_encode.hpp"
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string S1, S2;
    cin >> S1 >> S2;

    string S = S1 + S2;

    auto rle = run_length_encode(S);

    int ans = 0;
    for (auto [c, n] : rle)
    {
        if (c == 'o')
        {
            ans = max(ans, n);
        }
    }

    cout << ans << endl;

    return 0;
}
#line 1 "test/String/run_length_encode/yukicoder-0203.cpp"
// competitive-verifier: PROBLEM https://yukicoder.me/problems/no/203

#line 1 "String/run_length_encode.hpp"
#include <bits/stdc++.h>
using namespace std;

template <typename Container>
vector<pair<typename Container::value_type, int>> run_length_encode(const Container &v)
{
    using T = typename Container::value_type;
    vector<pair<T, int>> result;

    for (const auto &n : v)
    {
        if (result.empty() || result.back().first != n)
        {
            result.push_back({n, 0});
        }

        result.back().second++;
    }

    return result;
}
#line 5 "test/String/run_length_encode/yukicoder-0203.cpp"

using namespace std;

int main()
{
    string S1, S2;
    cin >> S1 >> S2;

    string S = S1 + S2;

    auto rle = run_length_encode(S);

    int ans = 0;
    for (auto [c, n] : rle)
    {
        if (c == 'o')
        {
            ans = max(ans, n);
        }
    }

    cout << ans << endl;

    return 0;
}

Test cases

Env Name Status Elapsed Memory
g++ 99_system_test1.txt :heavy_check_mark: AC 5 ms 3 MB
g++ challenge01.txt :heavy_check_mark: AC 4 ms 3 MB
g++ system_test1.txt :heavy_check_mark: AC 4 ms 3 MB
g++ system_test2.txt :heavy_check_mark: AC 4 ms 3 MB
g++ system_test3.txt :heavy_check_mark: AC 4 ms 3 MB
g++ system_test4.txt :heavy_check_mark: AC 4 ms 3 MB
g++ system_test5.txt :heavy_check_mark: AC 4 ms 3 MB
g++ system_test6.txt :heavy_check_mark: AC 4 ms 3 MB
g++ system_test7.txt :heavy_check_mark: AC 5 ms 3 MB
g++ test1.txt :heavy_check_mark: AC 5 ms 3 MB
g++ test10.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test11.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test12.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test13.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test14.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test15.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test16.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test17.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test18.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test19.txt :heavy_check_mark: AC 5 ms 3 MB
g++ test2.txt :heavy_check_mark: AC 5 ms 3 MB
g++ test20.txt :heavy_check_mark: AC 5 ms 3 MB
g++ test3.txt :heavy_check_mark: AC 5 ms 3 MB
g++ test4.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test5.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test6.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test7.txt :heavy_check_mark: AC 4 ms 3 MB
g++ test8.txt :heavy_check_mark: AC 5 ms 3 MB
g++ test9.txt :heavy_check_mark: AC 5 ms 3 MB
Back to top page