Submission #251519

#TimeUsernameProblemLanguageResultExecution timeMemory
251519kostia244Jousting tournament (IOI12_tournament)C++17
0 / 100
92 ms12812 KiB
#include<bits/extc++.h> using namespace std; using namespace __gnu_pbds; struct range { int i, l, r; bool operator<(const range &rhs) const { return l < rhs.l; } }; using oset = tree<range, null_type, less<range>, rb_tree_tag, tree_order_statistics_node_update>; const int maxn = 1<<18; int n, c, x, l[maxn], r[maxn]; vector<int> g[maxn]; int tr[maxn]; int qry(int l, int r) { int ans = 0; for(l += n, r += n; l < r; l>>=1, r>>=1) { if(l&1) ans = max(ans, tr[l++]); if(r&1) ans = max(ans, tr[--r]); } return ans; } int dp[maxn]; int dfs(int v) { if(v < n) return 0; if(dp[v] >= 0) return dp[v]; int good = qry(l[v], r[v]) < x; dp[v] = good; for(auto &i : g[v]) dp[v] = max(dp[v], good+dfs(i)); return dp[v]; } int GetBestPosition(int N, int C, int X, int *a, int *s, int *e) { n = N, c = C, x = X; for(int i = 0; i < n; i++) { int j = n+i; for(;j;j>>=1) tr[j] = max(tr[j], a[i]); } oset b; for(int i = 0; i < n; i++) l[i] = r[i] = i, b.insert(range{i, l[i], r[i]}); for(int i = 0; i < c; i++) { int len = e[i] - s[i] + 1; int nl, nr; for(int j = 1; j <= len; j++) { auto t = *b.find_by_order(s[i]); if(j == 1) nl = t.l; if(j == len) nr = t.r; g[n+i].push_back(t.i); b.erase(t); } l[n+i] = nl; r[n+i] = nr; b.insert(range{n+i, nl, nr}); } memset(dp, -1, sizeof dp); int ans = 0; for(int i = 0; i < n+c; i++) ans = max(ans, dfs(i)); return ans; }

Compilation message (stderr)

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:44:11: warning: 'nr' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int nl, nr;
           ^~
tournament.cpp:44:7: warning: 'nl' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int nl, nr;
       ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...