제출 #104096

#제출 시각아이디문제언어결과실행 시간메모리
104096turbat커다란 상품 (IOI17_prize)C++14
컴파일 에러
0 ms0 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; using vi = vector <int>; using pii = pair <int, int>; #define pb push_back #define mp make_pairdefine F first #define S second #define N 200005 int mx, fen[N]; void add(int x){ x++; while(x < N){ fen[x]++; x += x & -x; } } int sum(int x){ x++; int s = 0; while (x){ s += fen[x]; x -= x & -x; } return s; } int gg(int l, int r){ vi tmp; if (l == r) { tmp = ask(l); add(l); if (!(tmp[0] + tmp[1])) return l; return -1; } while(l <= r){ tmp = ask(r); if (tmp[0] + tmp[1] == 0) return r; if (tmp[0] + tmp[1] == mx) break; add(r); r--; } if (l > r) return -1; if (tmp1[0] == sum(l - 1)) return -1; if (l == r) return gg(l, r); int mid = (l + r) / 2; return max(gg(l, mid), gg(mid + 1, r)); } int find_best(int n) { int s[505]; for (int i = 0;i < 500;i++){ vi ans = ask(i); s[i] = ans[0] + ans[1]; if (!s[i]) return i; mx = max(mx, s[i]); } for (int i = 0;i < 500;i++) if (s[i] != mx) add(i); return gg(500, n - 1); }

컴파일 시 표준 에러 (stderr) 메시지

prize.cpp: In function 'int gg(int, int)':
prize.cpp:45:6: error: 'tmp1' was not declared in this scope
  if (tmp1[0] == sum(l - 1)) return -1;
      ^~~~
prize.cpp:45:6: note: suggested alternative: 'tmp'
  if (tmp1[0] == sum(l - 1)) return -1;
      ^~~~
      tmp
prize.cpp: In function 'int find_best(int)':
prize.cpp:58:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i = 0;i < 500;i++)
  ^~~
prize.cpp:61:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   return gg(500, n - 1);
   ^~~~~~