Submission #120212

#TimeUsernameProblemLanguageResultExecution timeMemory
120212dantoh000JOIOJI (JOI14_joioji)C++14
95 / 100
32 ms3948 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; unordered_map<ll,int> m; ll f(int x, int y){ return (x<<17)^y; } int main(){ int n; scanf("%d",&n); int ans = 0; int a, b; 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("%d",ans); }

Compilation message (stderr)

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("%d",&n);
     ~~~~~^~~~~~~~~
joioji.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&x);
         ~~~~~^~~~~~~~~~
joioji.cpp:17:19: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
             a++; b++;
                  ~^~
joioji.cpp:17:14: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
             a++; b++;
             ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...