이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |