답안 #369761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369761 2021-02-22T11:33:54 Z MilosMilutinovic 식물 비교 (IOI20_plants) C++14
0 / 100
1 ms 380 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

int n, k;
vector<int> a;

int compare_plants(int x, int y) {
	assert(x>=0&&x<n&&y>=0&&y<n&&x!=y);
	if(x==n-1) {
		if(y==x-1) {
			if(!a[y])
				return -1;
			return 1;
		} else {
			if(y!=0)
				return 0;
			if(!a[x])
				return 1;
			return -1;
		}
	} else {
		if(x==0) {
			if(y==n-1) {
				if(!a[y])
					return -1;
				return 1;
			} else {
				if(y!=1)
					return 0;
				if(!a[x])
					return 1;
				return -1;
			}
		} else {
			if(abs(x-y)!=1)
				return 0;
			if(x<y) {
				if(!a[x])
					return 1;
				return -1;
			} else {
				if(!a[y])
					return -1;
				return 1;
			}
		}
	}
	assert(false);
}

void init(int K, vector<int> r) {
	n=(int)r.size(), k=K, a=r;
}

/*int main() {
	init(2, {0, 0, 1});
	cout << compare_plants(0, 2);
	return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 380 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -