답안 #1039845

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039845 2024-07-31T10:30:44 Z amirhoseinfar1385 식물 비교 (IOI20_plants) C++17
0 / 100
4000 ms 5456 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];
	}
}

int compare_plants(int x, int y) {
	for(int i=0;i<n;i++){
		fake[i]=all[i];
	}
	for(int i=0;i<n;i++){
		vector<int>tof;
		int vis1=0,vis2=0;
		for(int j=0;j<n;j++){
			if(fake[j]==0){
				tof.push_back(j);
			}
		//	cout<<"ha: "<<i<<" "<<j<<" "<<fake[j]<<endl;
		}
		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;
				}else if(tof[j]==y){
					vis2=1;
				}
			}
		}
		if((tof[0]-tof.back()+n)%n>=k||(int)tof.size()==1){
			tofy.push_back(tof[0]);
			if(tof[0]==x){
				vis1=1;
			}else if(tof[0]==y){
				vis2=1;
			}
		}
		//cout<<x<<" "<<y<<" "<<(int)tofy.size()<<" "<<vis1<<" "<<vis2<<endl;
		while((int)tofy.size()>0&&(tofy.back()==x||tofy.back()==y)){
			tofy.pop_back();
		}
	//	cout<<x<<" "<<y<<" "<<(int)tofy.size()<<" "<<vis1<<" "<<vis2<<endl;
	//	if((int)tofy.size()>0){
	//		cout<<tofy.back()<<endl;
	//	}
		if(vis1==1&&vis2==1){
			return 0;
		}
		if((int)tofy.size()==0){
			if(vis1){
				return 1;
			}else{
				return -1;
			}
		}
		for(int h=1;h<=k-1;h++){
			fake[(tofy.back()-h+n)%n]--;
		}
		fake[tofy.back()]=-1;
	}
	return 1;
}
# 결과 실행 시간 메모리 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 0 ms 348 KB Output is correct
6 Correct 427 ms 3044 KB Output is correct
7 Runtime error 24 ms 5456 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 5 ms 348 KB Output is correct
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 5 ms 348 KB Output is correct
6 Runtime error 1 ms 604 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 22 ms 5376 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 2 ms 344 KB Output is correct
6 Correct 99 ms 480 KB Output is correct
7 Execution timed out 4027 ms 860 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Runtime error 1 ms 348 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 348 KB Output is correct
6 Correct 427 ms 3044 KB Output is correct
7 Runtime error 24 ms 5456 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -