Submission #601238

#TimeUsernameProblemLanguageResultExecution timeMemory
601238FatihSolakComparing Plants (IOI20_plants)C++17
5 / 100
88 ms10224 KiB
#include "plants.h" #include <bits/stdc++.h> #define N 200005 using namespace std; int pre[2*N]; int revpre[2*N]; int n; void init(int k, vector<int> r){ n = r.size(); for(int i = 0;i<n;i++){ pre[i] = r[i]; revpre[i] = !r[i]; if(i){ pre[i] += pre[i-1]; revpre[i] += revpre[i-1]; } } for(int i = 0;i<n;i++){ pre[i+n] = r[i]; revpre[i+n] = !r[i]; pre[i+n] += pre[i+n-1]; revpre[i+n] += revpre[i+n-1]; } return; } int get(int l,int r){ return pre[r] - (l == 0?0:pre[l-1]); } int get2(int l,int r){ return revpre[r] - (l == 0?0:revpre[l-1]); } int compare_plants(int x, int y) { if(get(x,y-1) == 0){ return 1; } if(get2(x,y-1) == 0){ return -1; } if(get(y,x+n-1) == 0){ return -1; } if(get2(y,x+n-1) == 0){ 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...