답안 #1039860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039860 2024-07-31T10:57:25 Z amirhoseinfar1385 식물 비교 (IOI20_plants) C++17
14 / 100
205 ms 77136 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+10;
int all[maxn],tr[maxn],res[maxn][maxn],fake[maxn],allh[maxn];
int k,n,vis[maxn],visa[maxn];
vector<int>adj[maxn];

void clear(){
	for(int i=0;i<n;i++){
		visa[i]=0;
	}
}

void isc(int u,int av){
	visa[u]=1;
	res[av][u]=1;
	for(auto x:adj[u]){
		if(visa[x]==0){
			isc(x,av);
		}
	}
}

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 i=0;i<n;i++){
		fake[i]=all[i];
	}
	int cnt=n;
	for(int i=0;i<n;i++){
		vector<int>tof;
		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]);
				vis[tofy[j]]=1;
			}else{
				adj[tof[j-1]].push_back(tof[j]);
			}
		}
		if((tof[0]-tof.back()+n)%n>=k||(int)tof.size()==1){
			tofy.push_back(tof[0]);
			vis[tofy[0]]=1;
		}
		else{
			adj[tof.back()].push_back(tof[0]);
		}
		for(int h=1;h<=k-1;h++){
			fake[(tofy.back()-h+n)%n]--;
			if(vis[(tofy.back()-h+n)%n]==0){
				adj[tofy.back()].push_back((tofy.back()-h+n)%n);
			}
		}
		vis[tofy.back()]=1;
		fake[tofy.back()]=-1;
		allh[tofy.back()]=cnt;
		cnt--;
	}
}

int compare_plants(int x, int y) {
	if(allh[x]>allh[y]){
		return 1;
	}
	if(allh[y]>allh[x]){
		return -1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Incorrect 0 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 7 ms 4956 KB Output is correct
7 Correct 153 ms 55640 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 7 ms 5020 KB Output is correct
10 Correct 159 ms 55636 KB Output is correct
11 Correct 187 ms 77136 KB Output is correct
12 Correct 119 ms 56916 KB Output is correct
13 Correct 205 ms 66828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 7 ms 4956 KB Output is correct
7 Correct 153 ms 55640 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 7 ms 5020 KB Output is correct
10 Correct 159 ms 55636 KB Output is correct
11 Correct 187 ms 77136 KB Output is correct
12 Correct 119 ms 56916 KB Output is correct
13 Correct 205 ms 66828 KB Output is correct
14 Runtime error 26 ms 5816 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Runtime error 28 ms 10096 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 0 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Incorrect 0 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -