제출 #613764

#제출 시각아이디문제언어결과실행 시간메모리
613764Koosha_mv식물 비교 (IOI20_plants)C++14
0 / 100
4054 ms7628 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,int(v.size())) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=505; int n,k,p[N],a[N],vis[N]; vector<int> g[N]; void dfs1(int u){ vis[u]=1; for(auto v : g[u]){ if(vis[v]) continue ; dfs1(v); } } void init(int _k,vector<int> _p) { n=_p.size(),k=_k; f(i,0,n) p[i]=_p[i]; int last=0; f_(T,n-1,0){ f(i,0,2*n){ if(p[i%n]==0){ if(i>=n && i-last>=k){ a[i-n]=T; f(j,0,k){ p[(i-j)%n]--; } break ; } last=i; } } } f(i,0,n){ f(j,1,k){ if(a[i]<a[(i+j)%n]){ g[i].pb((i+j)%n); } else{ g[(i+j)%n].pb(i); } } } } int compare_plants(int x, int y) { fill(vis,vis+n,0); dfs1(x); if(vis[y]) return -1; fill(vis,vis+n,0); dfs1(y); if(vis[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...