Submission #589404

#TimeUsernameProblemLanguageResultExecution timeMemory
589404LucppComparing Plants (IOI20_plants)C++17
0 / 100
45 ms4052 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; int n, k; vector<int> dpL, dpR; void init_k2(vector<int> r){ dpL.resize(n), dpR.resize(n); for(int it = 0; it < 2; it++) for(int i = 0; i < n; i++){ if(r[i]) dpR[i] = dpR[(i+1)%n]+1; if(!r[(i+n-1)%n]) dpL[i] = dpL[(i+n-1)%n]+1; } } void init_else(vector<int> r){ } void init(int K, vector<int> r) { k = K; n = (int)r.size(); if(k == 2) init_k2(r); else init_else(r); } int compare_k2(int x, int y){ int d1 = (y-x+n)%n; int d2 = n-d1; if(dpR[x] >= d1 || dpL[x] >= d2) return -1; if(dpR[y] >= d2 || dpL[y] >= d1) return 1; return 0; } int compare_else(int x, int y){ return 0; } int compare_plants(int x, int y) { if(k == 2) return compare_k2(x, y); else return compare_else(x, y); }
#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...