Submission #738110

#TimeUsernameProblemLanguageResultExecution timeMemory
738110bobthebuilderComparing Plants (IOI20_plants)C++17
0 / 100
4 ms5028 KiB
#include "plants.h" #include<bits/stdc++.h> using namespace std; #define sz(x) (int)x.size() #define REP(i,n) for(int i=0;i<n;i++) #define REP1(i,n) for(int i=1;i<=n;i++) #define pb push_back #define lowb(x) (x&(-x)) #define ALL(_x) _x.begin(),_x.end() #define pii pair<int,int> #define f first #define s second #define SORT_UNIQUE(x) sort(ALL(x)),x.erase(unique(ALL(x)),x.end()) #define ll long long #define MNTO(x,y) x=min(x,y) #define MXTO(x,y) x=max(x,y) const int maxn=2e5+5; vector<int> v[maxn]; int dep[maxn]; int in[maxn]; int l[maxn],r[maxn]; void dfs(int u){ l[u]=r[u]=u; for(int x:v[u]){ dfs(x); MNTO(l[u],l[x]),MXTO(r[u],r[x]); } } void init(int k, std::vector<int> r) { int n=sz(r); REP(i,n){ if(r[i]==1){ v[(i+1)%n].pb(i),in[i]++; } else v[i].pb((i+1)%n),in[(i+1)%n]++; } REP(i,n){ if(!in[i]){ dfs(i); } } } int compare_plants(int x, int y) { if(l[x]<=y and y<=r[x]){ return 1; } if(l[y]<=x and x<=r[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...