Submission #328539

#TimeUsernameProblemLanguageResultExecution timeMemory
328539sumit_kk10JOIOJI (JOI14_joioji)C++14
100 / 100
44 ms6136 KiB
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) #define ll long long int #define ld long double using namespace std; const int N = 1e6 + 5; const int MOD = 1e9 + 7; void solve(){ int n, j = 0, ii = 0, ans = 0, o = 0; cin >> n; string s; cin >> s; map<pair<int, int>, int> mp; mp[{0, 0}] = 0; for(int i = 0; i < s.size(); ++i){ if(s[i] == 'J') ++j; if(s[i] == 'O') ++o; if(s[i] == 'I') ++ii; if(mp.find({j - o, j - ii}) == mp.end()) mp[{j - o, j - ii}] = i + 1; else ans = max(ans, i + 1 - mp[{j - o, j - ii}]); } cout << ans << '\n'; } int main(){ fast; int t = 1; // cin >> t; while(t--) solve(); return 0; }

Compilation message (stderr)

joioji.cpp: In function 'void solve()':
joioji.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i = 0; i < s.size(); ++i){
      |                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...