Submission #303357

# Submission time Handle Problem Language Result Execution time Memory
303357 2020-09-20T08:55:50 Z Utaha Comparing Plants (IOI20_plants) C++14
11 / 100
67 ms 5752 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 305;
#define REP(i,n) for(int i=0;i<(n);i++)
#define eb emplace_back
#define pb push_back
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(),a.end()
int n,k;

bool vis[maxn];

bool adj[maxn][maxn];

void init(int _k, std::vector<int> _r) {
	vector<int> r = _r;
	n = r.size();
	k = _k;
	int cnt = 0;
	while(cnt<n){
		vector<int> idx;
		REP(j,n) if(!vis[j]){
			if(r[j]==0) idx.pb(j);
		}
		// for(int i:idx){
		// 	cout<<i<<' ';
		// }
		// cout<<endl;

		idx.pb(idx[0]+n);
		REP(i,SZ(idx)-1){
			if(idx[i+1]-idx[i]>=k){
				int t = idx[i+1]%n;
				vis[t] = 1;
				REP(j,k-1){
					int nxt = (t+1+j)%n;
					if(!vis[nxt]) adj[t][nxt] = 1;
				}
				cnt++;
				REP(j,k-1){
					int pre = (t-j-1+n)%n;
					if(!vis[pre]) r[pre]--;
				}
			}
		}
	}


	r = _r;
	cnt = 0;
	REP(i,n) vis[i]=0;
	while(cnt<n){
		vector<int> idx;
		REP(j,n) if(!vis[j]){
			if(r[j]==k-1) idx.pb(j);
		}
		// for(int i:idx){
		// 	cout<<i<<' ';
		// }
		// cout<<endl;

		idx.pb(idx[0]+n);
		REP(i,SZ(idx)-1){
			if(idx[i+1]-idx[i]>=k){
				int t = idx[i+1]%n;
				vis[t] = 1;
				REP(j,k-1){
					int nxt = (t+1+j)%n;
					if(!vis[nxt]) adj[nxt][t] = 1;
				}
				cnt++;
				REP(j,k-1){
					int pre = (t-j-1+n)%n;
					if(!vis[pre]) r[pre]++;
				}
			}
		}
	}







	REP(j,n) REP(i,n) REP(k,n){
		if(adj[i][j]&&adj[j][k]) adj[i][k] = 1;
	}

	return;
}


int compare_plants(int x, int y) {
	if(adj[x][y]) return 1;
	else if(adj[y][x]) return -1;
	else return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 67 ms 3192 KB Output is correct
7 Runtime error 63 ms 5752 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Runtime error 2 ms 512 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Runtime error 2 ms 512 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Runtime error 59 ms 5240 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 43 ms 1016 KB Output is correct
8 Correct 55 ms 1016 KB Output is correct
9 Correct 45 ms 1016 KB Output is correct
10 Correct 54 ms 1016 KB Output is correct
11 Correct 42 ms 1016 KB Output is correct
12 Correct 46 ms 1016 KB Output is correct
13 Correct 57 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Runtime error 2 ms 512 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 67 ms 3192 KB Output is correct
7 Runtime error 63 ms 5752 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -