Submission #684838

#TimeUsernameProblemLanguageResultExecution timeMemory
684838stevancvJousting tournament (IOI12_tournament)C++14
0 / 100
138 ms2204 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 1e5 + 2; const int inf = 1e9; int l[N], r[N], ans[N], gde[N]; vector<int> b; bool Has(int x, int y) { auto it = lower_bound(b.begin(), b.end(), x); if (it == b.end()) return false; return *it < y; } int GetBestPosition(int n, int q, int k, int *p, int *s, int *e) { for (int i = 0; i < n - 1; i++) if (p[i] > k) b.push_back(i); for (int i = 0; i < n; i++) l[i] = r[i] = gde[i] = i; for (int i = 0; i < q; i++) { int idx = gde[s[i]]; int idy = gde[e[i]]; r[idx] = r[idy]; for (int i = s[i] + 1; i <= n - 1 - e[i] + s[i]; i++) gde[i] = gde[i + e[i] - s[i]]; if (!Has(l[idx], r[idx])) { ans[l[idx]]++; ans[r[idx] + 1]--; } } int pos = 0; for (int i = 0; i < n; i++) { if (i > 0) ans[i] += ans[i - 1]; if (ans[i] > ans[pos]) pos = i; } return pos; }

Compilation message (stderr)

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:24:24: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |         for (int i = s[i] + 1; i <= n - 1 - e[i] + s[i]; i++) gde[i] = gde[i + e[i] - s[i]];
      |                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...