답안 #1050236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050236 2024-08-09T08:08:25 Z TahirAliyev 식물 비교 (IOI20_plants) C++17
14 / 100
100 ms 9964 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

const int MAX = 5005;
int id[MAX];
int pre[MAX];
int n;
int ask(int l, int r){
	if(r < l){
		return pre[n] - (pre[l - 1] - pre[r]);
	}
	return pre[r] - pre[l - 1];
}
void init(int k, vector<int> r) {
	n = r.size();
	vector<int> zer;
	r.insert(r.begin(), 0);
	for(int i = 1; i <= n; i++){
		if(!r[i]) zer.push_back(i);
	}
	int t = n;
	while(zer.size()){
		for(int i = 1; i <= n; i++){
			pre[i] = pre[i - 1] + (!r[i]);
		}
		int f = 0, l = 0;
		for(int a : zer){
			l = a - k + 1;
			if(l <= 0) l += n;
			if(!ask(l, a - 1)){
				f = a;
				break;
			}
		}
		l = f - k + 1;
		if(l <= 0) l += n;
		r[f] = 1e9;
		id[f] = t--;
		for(int i = l; ; i++){
			if(i == f) break;
			if(i > n){
				i = 0;
				continue;
			}
			r[i]--;
			if(r[i] == 0) zer.push_back(i);
		}
		zer.erase(find(zer.begin(), zer.end(), f));
	}
	// for(int i = 1; i <= n; i ++){
	// 	cout << id[i] << ' ';
	// }
	// cout << '\n';
}

int compare_plants(int x, int y) {
	x++, y++;
	if(id[x] > id[y]) return 1;
	else return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 99 ms 4948 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 93 ms 3132 KB Output is correct
11 Correct 70 ms 3156 KB Output is correct
12 Correct 70 ms 3408 KB Output is correct
13 Correct 100 ms 3132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 99 ms 4948 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 93 ms 3132 KB Output is correct
11 Correct 70 ms 3156 KB Output is correct
12 Correct 70 ms 3408 KB Output is correct
13 Correct 100 ms 3132 KB Output is correct
14 Runtime error 22 ms 5700 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 29 ms 4956 KB Output is correct
4 Runtime error 33 ms 9964 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 444 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -