답안 #303325

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
303325 2020-09-20T08:05:33 Z Utaha 식물 비교 (IOI20_plants) C++14
0 / 100
66 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
int n,k;

vector<int> child[maxn];
bool vis[maxn][maxn];


void init(int _k, std::vector<int> r) {
	n = r.size();
	k = _k;

	REP(i,n){
		if(r[i]==0){
			for(int j=i+1;j<i+k;j++){
				child[i].eb(j%n);
			}
		}
		else if(r[i]==k-1){
			for(int j=i+1;j<i+k;j++){
				child[j%n].eb(i);
			}
		}
	}

	REP(i,n) for(int j:child[i]){
		vis[i][j] = 1;
	}
	REP(j,n) REP(i,n) REP(k,n){
		if(vis[i][j]&&vis[j][k]) vis[i][k]=1;
	}
	return;
}

// bool between(int idx,int l,int r){
// 	if(l<=idx&&idx<r) return 1;
// 	if(l<=idx+n&&idx+n<r) return 1;
// 	// cout<<idx<<' '<<l<<' '<<r<<endl;
// 	return 0;
// }

int compare_plants(int x, int y) {
	// if(between(y,x,x+k)){
	// 	if(v[x]==0) return 1;
	// 	else if(v[x] == k-1) return -1;
	// }
	// if(between(x,y,y+k)){
	// 	if(v[y]==0) return -1;
	// 	else if(v[y] == k-1) return 1;
	// }
	// return 0;

	if(vis[x][y]) return 1;
	else if(vis[y][x]) return -1;
	else return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 63 ms 3192 KB Output is correct
7 Runtime error 66 ms 5752 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 0 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 0 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 63 ms 3192 KB Output is correct
7 Runtime error 66 ms 5752 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -