답안 #303539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
303539 2020-09-20T11:44:03 Z leejseo 식물 비교 (IOI20_plants) C++17
5 / 100
115 ms 5880 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

int N, K;
int R[200005];
int _P[200005];
int *P = _P+1;

void init(int k, vector<int> r) {
	K = k;
	N = r.size();
	for (int i=0; i<N; i++) R[i] = r[i];
	for (int i=0; i<N; i++){
		if (R[i] != R[(i+1)%N]) P[(i+1)%N]++;
	}
	for (int i=0; i<N; i++){
		P[i+1] += P[i];
	}
}

int compare_plants(int x, int y) {
	// [x, y)
	if (P[x] == P[y-1]){
		// 증감 같은 구간
		return R[x] == 1 ? -1 : 1;
	}
	else if (P[y] == P[N-1] && P[x-1] == 0){
		// 사이에 N 끼는 증감 같은 구간
		return R[y] == 1 ? 1 : -1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 65 ms 3192 KB Output is correct
7 Correct 102 ms 3448 KB Output is correct
8 Correct 108 ms 5752 KB Output is correct
9 Correct 114 ms 5756 KB Output is correct
10 Correct 115 ms 5752 KB Output is correct
11 Correct 113 ms 5880 KB Output is correct
12 Correct 111 ms 5752 KB Output is correct
13 Correct 107 ms 5752 KB Output is correct
14 Correct 104 ms 5752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 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 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 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 0 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 65 ms 3192 KB Output is correct
7 Correct 102 ms 3448 KB Output is correct
8 Correct 108 ms 5752 KB Output is correct
9 Correct 114 ms 5756 KB Output is correct
10 Correct 115 ms 5752 KB Output is correct
11 Correct 113 ms 5880 KB Output is correct
12 Correct 111 ms 5752 KB Output is correct
13 Correct 107 ms 5752 KB Output is correct
14 Correct 104 ms 5752 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Incorrect 1 ms 256 KB Output isn't correct
18 Halted 0 ms 0 KB -