Submission #430659

#TimeUsernameProblemLanguageResultExecution timeMemory
430659OzyComparing Plants (IOI20_plants)C++17
0 / 100
1 ms204 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; #define lli int #define rep(i,a,b) for (lli i = (a); i <= (b); i++) #define repa(i,a,b) for (lli i = (a); i >= (b); i--) #define debug(a) cout << #a << " = " << a << endl; #define debugsl(a) cout << #a << " = " << a << ", "; #define MAX 200000 lli n,pos; lli pm[MAX+2]; vector<int> sig; lli recurcion(lli pos, lli i) { lli y = pos; pos++; if (pos >= n) pos = 0; if (sig[pos] == sig[i]) { pm[y] = recurcion(pos,i); return pm[y]; } else { pm[y] = pos; return pos; } } void init(int k, std::vector<int> r) { n = r.size(); cout << n; sig = vector<int> (n, 0); rep(i,0,n-1) { pm[i] = -1; sig[i] = r[i]; } rep(i,0,n-1) if (pm[i] == -1) pm[i] = recurcion(i,i); } int compare_plants(int x, int y) { lli res; if (x > y) { swap(x,y); res = -1; } else res = 1; if (pm[x] >= y || pm[x] < x) { if (sig[x] == 1) res *= -1; } else if (pm[y] >= x && pm[y] < y) { if (sig[y] == 0) res *= -1; } else return 0; return res; }
#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...