Submission #772642

#TimeUsernameProblemLanguageResultExecution timeMemory
772642hgmhcJOIOJI (JOI14_joioji)C++17
100 / 100
33 ms6064 KiB
#include <bits/stdc++.h> using namespace std; using ii = pair<int,int>; using ll = long long; #define rep(i,a,b) for (auto i = (a); i <= (b); ++i) #define per(i,a,b) for (auto i = (b); i >= (a); --i) #define all(x) begin(x), end(x) #define siz(x) int((x).size()) #define Mup(x,y) x = max(x,y) #define mup(x,y) x = min(x,y) #define fi first #define se second #define dbg(...) fprintf(stderr,__VA_ARGS__) const int N = 2e5+3; int n, ans; char s[N]; map<ii,ii> m; int main() { scanf("%d %s ", &n, s+1); int j=0, o=0, i=0; m[{0,0}]={0,0}; rep(k,1,n) { if(s[k]=='J')j++; if(s[k]=='O')o++; if(s[k]=='I')i++; if (m.count({j-o,o-i})) m[{j-o,o-i}].se = k; else m[{j-o,o-i}] = {k,k}; } for (auto [k,v] : m) Mup(ans, v.se-v.fi); printf("%d", ans); }

Compilation message (stderr)

joioji.cpp: In function 'int main()':
joioji.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d %s ", &n, s+1);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...