Submission #39681

#TimeUsernameProblemLanguageResultExecution timeMemory
3968114kgJOIOJI (JOI14_joioji)C++11
100 / 100
33 ms24340 KiB
#include <stdio.h> #include <map> #define P 66667 #define N 200005 #define INF 999999999 #define Abs(x) (x>0?x:-(x)) #define max2(x,y) (x>y?x:y) using namespace std; int n; char in[N]; map<int, int> M[N * 2]; int Find(int x, int y, int w) { if (x == 0 && y == 0) return 0; int res = M[x + n][y]; if (!res) M[x + n][y] = w; return res ? res : INF; } int main() { int x = 0, y = 0, w, out = 0; scanf("%d %s", &n, in + 1); for (int i = 1; i <= n; i++) { if (in[i] == 'J') x++, y++; else if (in[i] == 'O') x--; else y--; w = Find(x, y, i), out = max2(out, i - w); } printf("%d", out); }

Compilation message (stderr)

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