Submission #1039866

# Submission time Handle Problem Language Result Execution time Memory
1039866 2024-07-31T11:03:01 Z amirhoseinfar1385 Comparing Plants (IOI20_plants) C++17
11 / 100
840 ms 6008 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=300+10;
int all[maxn],tr[maxn],res[maxn][maxn],fake[maxn];
int k,n;
 
void init(int k_, std::vector<int> r) {
	k=k_;
	n=(int)r.size();
	for(int i=0;i<n;i++){
		all[i]=r[i];
	}
	for(int x=0;x<n;x++){
		vector<int>nago(n+2);
		for(int i=0;i<n;i++){
			fake[i]=all[i];
		}
		for(int i=0;i<n;i++){
			vector<int>tof;
			int vis1=0;
			for(int j=0;j<n;j++){
				if(fake[j]==0){
					tof.push_back(j);
				}
			}
			vector<int>tofy;
			for(int j=(int)tof.size()-1;j>0;j--){
				if(tof[j]-tof[j-1]>=k){
					tofy.push_back(tof[j]);
					if(tof[j]==x){
						vis1=1;
					}
				}
			}
			if((tof[0]-tof.back()+n)%n>=k||(int)tof.size()==1){
				tofy.push_back(tof[0]);
				if(tof[0]==x){
					vis1=1;
				}
			}
			while((int)tofy.size()>0&&(tofy.back()==x)){
				tofy.pop_back();
			}
			if((int)tofy.size()==0){
				for(int j=0;j<n;j++){
					if(nago[j]==0){
						res[x][j]=1;
					}
				}
				break;
			}
			nago[tofy.back()]=1;
			if(vis1){
				res[x][tofy.back()]=2;
			}
			for(int h=1;h<=k-1;h++){
				fake[(tofy.back()-h+n)%n]--;
			}
			fake[tofy.back()]=-1;
		}
	}
}



int compare_plants(int x, int y) {
	if(res[x][y]==2||res[y][x]==2){
		return 0;
	}
	if(res[x][y]==1){
		return 1;
	}
	return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 30 ms 3156 KB Output is correct
7 Runtime error 25 ms 5444 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Runtime error 361 ms 1364 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Runtime error 361 ms 1364 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 840 ms 6008 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 4 ms 604 KB Output is correct
7 Correct 45 ms 1316 KB Output is correct
8 Correct 30 ms 1372 KB Output is correct
9 Correct 36 ms 1264 KB Output is correct
10 Correct 31 ms 1364 KB Output is correct
11 Correct 41 ms 1372 KB Output is correct
12 Correct 35 ms 1360 KB Output is correct
13 Correct 43 ms 1216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Runtime error 190 ms 1260 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 30 ms 3156 KB Output is correct
7 Runtime error 25 ms 5444 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -