답안 #819836

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
819836 2023-08-10T14:04:52 Z Abrar_Al_Samit 식물 비교 (IOI20_plants) C++17
5 / 100
75 ms 10220 KB
#include <bits/stdc++.h>
#include "plants.h"
using namespace std;

const int nax = 2e5 + 2;
int n, k;
int head[nax][2], pos[nax][2];

void init(int K, vector<int> r) {
	k = K;
	n = r.size();
	memset(head, -1, sizeof head);

	int p = -1;
	for(int i=0; i<n; ++i) {
		int pr = (i - 1 + n) % n;

		if(!r[pr] && r[i]) { //down
			p = i;
			break;
		}
	}
	assert(p!=-1);

	int st = p;
	while(1) {
		int j = p;
		pos[p][0] = 1;
		head[p][0] = p;
		int at = 1;
		while(r[j]) {
			j = (j+1)%n;
			head[j][0] = p;
			pos[j][0] = ++at;
		}

		p = j;
		head[p][1] = p;
		pos[p][1] = 1;
		at = 1;
		while(!r[j]) {
			j = (j+1)%n;
			head[j][1] = p;
			pos[j][1] = ++at;
		}

		if(j==st) break;
		p = j;
	}
}

int compare_plants(int x, int y) {
	if(head[x][0] == head[y][0] && head[x][0] != -1) {
		return (pos[x][0] < pos[y][0]) ? -1 : 1;
	}
	if(head[x][1] == head[y][1] && head[x][1] != -1) {
		return (pos[x][1] > pos[y][1]) ? -1 : 1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 41 ms 5580 KB Output is correct
7 Correct 54 ms 7072 KB Output is correct
8 Correct 61 ms 10188 KB Output is correct
9 Correct 75 ms 10188 KB Output is correct
10 Correct 60 ms 10212 KB Output is correct
11 Correct 61 ms 10220 KB Output is correct
12 Correct 61 ms 10204 KB Output is correct
13 Correct 59 ms 10212 KB Output is correct
14 Correct 72 ms 10184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Incorrect 1 ms 1876 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Incorrect 1 ms 1876 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Incorrect 1 ms 1876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Incorrect 1 ms 1840 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Incorrect 1 ms 1876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 41 ms 5580 KB Output is correct
7 Correct 54 ms 7072 KB Output is correct
8 Correct 61 ms 10188 KB Output is correct
9 Correct 75 ms 10188 KB Output is correct
10 Correct 60 ms 10212 KB Output is correct
11 Correct 61 ms 10220 KB Output is correct
12 Correct 61 ms 10204 KB Output is correct
13 Correct 59 ms 10212 KB Output is correct
14 Correct 72 ms 10184 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1748 KB Output is correct
17 Incorrect 1 ms 1876 KB Output isn't correct
18 Halted 0 ms 0 KB -