Submission #1015123

#TimeUsernameProblemLanguageResultExecution timeMemory
1015123u_suck_oComparing Plants (IOI20_plants)C++17
14 / 100
4075 ms9796 KiB
#include "bits/stdc++.h" #include "plants.h" #define MAXN 200005 using namespace std; int pref[MAXN]; int h[MAXN]; int n; void init(int k, vector<int> r) { n = r.size(); r.insert(r.begin() + 0, -1); for (int height = n; height >= 1; height--) { vector<int> zeroes; pref[0] = 0; for (int i = 1; i <= n; i++) { pref[i] = pref[i-1]; if (r[i] == 0) { pref[i]++; zeroes.push_back(i); } } int z = -1; for (int x : zeroes) { if (x-k+1 > 0) { if (pref[x-1] - pref[x-k] == 0) { z = x; break; } } else { if (pref[x-1] == 0 && pref[n] - pref[x-k+n] == 0) { z = x; break; } } } r[z] = INT_MAX; h[z] = height; for (int i = z-k+1; i < z; i++) { if (i >= 1) r[i]--; else r[i + n]--; } } return; } int compare_plants(int x, int y) { if (h[x+1] > h[y+1]) return 1; else return -1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...