Submission #173428

#TimeUsernameProblemLanguageResultExecution timeMemory
173428jhwest2JOIOJI (JOI14_joioji)C++14
100 / 100
46 ms6276 KiB
#include <bits/stdc++.h> #define va first #define vb second using namespace std; typedef long long ll; typedef pair<int, int> pii; int N; string s; map<pii, int> mp; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> N >> s; int ans = 0; pii ret = {0, 0}; mp[ret] = 0; for (int i=0; i<s.size(); i++) { if (s[i] == 'J') ++ret.va, ++ret.vb; if (s[i] == 'O') --ret.va; if (s[i] == 'I') --ret.vb; if (mp.find(ret) == mp.end()) mp[ret] = i+1; else ans = max(ans, i+1 - mp[ret]); } cout << ans; }

Compilation message (stderr)

joioji.cpp: In function 'int main()':
joioji.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  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...