Submission #302443

#TimeUsernameProblemLanguageResultExecution timeMemory
302443arnold518Comparing Plants (IOI20_plants)C++14
0 / 100
64 ms5624 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 5000; int N, K, R[MAXN+10]; int adj[MAXN+10][MAXN+10]; bool vis[MAXN+10]; void dfs(int now, int root) { vis[now]=true; for(int i=0; i<N; i++) { if(adj[now][i]==0) continue; if(vis[i]) continue; adj[root][i]=1; dfs(i, root); } } void init(int _K, vector<int> _R) { K=_K; N=_R.size(); for(int i=0; i<N; i++) R[i]=_R[i]; for(int i=0; i<N; i++) { if(R[i]==0) { for(int j=1; j<K; j++) { adj[(i+j)%N][i]=1; } } if(R[i]==K-1) { for(int j=1; j<K; j++) { adj[i][(i+j)%N]=1; } } } for(int i=0; i<N; i++) { if(R[i]<R[(i+1)%N]) { adj[(i+1)%N][i]=1; } if(R[i]>R[(i+1)%N]) { adj[i][(i+1)%N]=1; } } for(int i=0; i<N; i++) { memset(vis, 0, sizeof(vis)); dfs(i, i); } return; } int compare_plants(int x, int y) { int ans=0; if(adj[x][y]==1) return -1; if(adj[y][x]==1) return 1; return 0; }

Compilation message (stderr)

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:71:6: warning: unused variable 'ans' [-Wunused-variable]
   71 |  int ans=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...