test/String/run_length_encode/yukicoder-0203.cpp
- View this file on GitHub
- Last update: 2025-05-02 22:16:20+09:00
- Problem: https://yukicoder.me/problems/no/203
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 |
![]() |
5 ms | 3 MB |
g++ | challenge01.txt |
![]() |
4 ms | 3 MB |
g++ | system_test1.txt |
![]() |
4 ms | 3 MB |
g++ | system_test2.txt |
![]() |
4 ms | 3 MB |
g++ | system_test3.txt |
![]() |
4 ms | 3 MB |
g++ | system_test4.txt |
![]() |
4 ms | 3 MB |
g++ | system_test5.txt |
![]() |
4 ms | 3 MB |
g++ | system_test6.txt |
![]() |
4 ms | 3 MB |
g++ | system_test7.txt |
![]() |
5 ms | 3 MB |
g++ | test1.txt |
![]() |
5 ms | 3 MB |
g++ | test10.txt |
![]() |
4 ms | 3 MB |
g++ | test11.txt |
![]() |
4 ms | 3 MB |
g++ | test12.txt |
![]() |
4 ms | 3 MB |
g++ | test13.txt |
![]() |
4 ms | 3 MB |
g++ | test14.txt |
![]() |
4 ms | 3 MB |
g++ | test15.txt |
![]() |
4 ms | 3 MB |
g++ | test16.txt |
![]() |
4 ms | 3 MB |
g++ | test17.txt |
![]() |
4 ms | 3 MB |
g++ | test18.txt |
![]() |
4 ms | 3 MB |
g++ | test19.txt |
![]() |
5 ms | 3 MB |
g++ | test2.txt |
![]() |
5 ms | 3 MB |
g++ | test20.txt |
![]() |
5 ms | 3 MB |
g++ | test3.txt |
![]() |
5 ms | 3 MB |
g++ | test4.txt |
![]() |
4 ms | 3 MB |
g++ | test5.txt |
![]() |
4 ms | 3 MB |
g++ | test6.txt |
![]() |
4 ms | 3 MB |
g++ | test7.txt |
![]() |
4 ms | 3 MB |
g++ | test8.txt |
![]() |
5 ms | 3 MB |
g++ | test9.txt |
![]() |
5 ms | 3 MB |