Submission #864910

#TimeUsernameProblemLanguageResultExecution timeMemory
864910andrei_boacaComparing Plants (IOI20_plants)C++17
0 / 100
2 ms8284 KiB
#include "plants.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; vector<int> muchii[200005]; int n,bigger[200005],smaller[200005],lastsmall[200005],lastbig[200005]; bool use[200005]; int dist(int a,int b) { return (b-a+n)%n; } void init(int k, std::vector<int> r) { n=r.size(); for(int i=0;i<n;i++) { if(r[i]==0) { int j=(i-1+n)%n; while(r[j]==1) { lastbig[j]=i; j=(j-1+n)%n; } } if(r[i]==1) { int j=(i-1+n)%n; while(r[j]==0) { lastsmall[j]=i; j=(j-1+n)%n; } } } } int compare_plants(int x, int y) { if(dist(x,y)+dist(y,lastsmall[x])==dist(x,lastsmall[x])) return -1; if(dist(x,y)+dist(y,lastbig[x])==dist(x,lastbig[x])) return 1; if(dist(y,x)+dist(x,lastsmall[y])==dist(y,lastsmall[y])) return 1; if(dist(y,x)+dist(x,lastbig[y])==dist(y,lastbig[y])) 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...