Submission #603783

#TimeUsernameProblemLanguageResultExecution timeMemory
603783HamletPetrosyanComparing Plants (IOI20_plants)C++17
5 / 100
73 ms5836 KiB
#include "plants.h" #include <iostream> using namespace std; #define len(a) ((int)(a).size()) vector<int> p, m; void init(int k, vector<int> r) { p.resize(len(r)); m.resize(len(r)); for(int i = 0, pr, now; i < 2 * len(r); i++){ now = i % len(r); pr = (now == 0) ? len(r) - 1 : now - 1; p[now] = m[now] = now; if(r[pr] == 0){ p[now] = p[pr]; } else { m[now] = m[pr]; } } // for(int i = 0; i < len(p); i++){ // cout << p[i] << " "; // } // cout << endl; // for(int i = 0; i < len(m); i++){ // cout << m[i] << " "; // } // cout << endl; } int compare_plants(int x, int y) { if(x < y){ if(p[x] > x && p[x] <= y) return -1; if(m[y] <= x || m[y] > y) return -1; if(m[x] > x && m[x] <= y) return 1; if(p[y] <= x || p[y] > y) return 1; return 0; } if(p[x] <= y || p[x] > x) return -1; if(m[y] > y && m[y] <= x) return -1; if(m[x] <= y || m[x] > x) return 1; if(p[y] > y && p[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...