Submission #438569

#TimeUsernameProblemLanguageResultExecution timeMemory
438569AmineTrabelsiComparing Plants (IOI20_plants)C++14
0 / 100
1 ms304 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; const int M = 200005; int pref[M]; int n; int sum(int l,int r){ //cerr << l <<" "<<r<<endl; if(r < l){ return sum(0,r)+sum(l,n-1); } return pref[r+1]-pref[l]; } void init(int k, vector<int> r) { n = r.size(); for(int i=0;i<n;i++){ pref[i+1] = pref[i]+r[i]; } return; } bool istaller(int x,int y){ //cerr <<sum(x,(y > 0 ? y-1 : n-1))<<" "<<x<<" "<<(y > 0 ? y-1 : n-1)<<" "<<endl; if(sum(x,(y > 0 ? y-1 : n-1)) == 0)return true; int range = sum(0,n-1)-sum(x,y); if(range == n-abs(x-y)-1)return true; return false; } int compare_plants(int x, int y) { //cerr << 1 << endl; if(istaller(x,y))return 1; //scerr << 2 << endl; if(istaller(y,x))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...