Submission #120217

#TimeUsernameProblemLanguageResultExecution timeMemory
120217dantoh000JOIOJI (JOI14_joioji)C++14
100 / 100
30 ms3984 KiB
#include <bits/stdc++.h> #define int long long using namespace std; unordered_map<int,int> m; int f(int x, int y){ return (x<<17)^y; } main(){ int n; scanf("%lld",&n); int ans = 0; int a = 0, b= 0; m[0] = -1; for (int i = 0; i < n; i++){ char x; scanf(" %c",&x); if (x == 'J'){ a++; b++; } else if (x == 'O') a--; else if (x == 'I') b--; int k = f(a,b); if (m[k] == 0){ m[k] = i; } else{ ans = max(ans,i-m[k]); } } printf("%lld",ans); }

Compilation message (stderr)

joioji.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
joioji.cpp: In function 'int main()':
joioji.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
joioji.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&x);
         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...