답안 #769040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
769040 2023-06-29T05:26:54 Z ono_de206 식물 비교 (IOI20_plants) C++14
14 / 100
4000 ms 4940 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

vector<int> a;
set<int> s;
int n, k;

bool check(int i) {
	if(s.size() == 1) return 1;
	s.erase(i);
	auto l = s.lower_bound(i);
	if(l == s.begin()) l = s.end();
	l--;
	if((i - (*l) + n) % n < k) {
		s.in(i);
		return 0;
	}
	s.in(i);
	return 1;
}

void init(int _k, vector<int> r) {
	k = _k;
	n = r.size();
	a.resize(n);
	for(int i = 0; i < n; i++) {
		if(r[i] == 0) s.in(i);
	}
	int now;
	for(int i = 0; i < n; i++) {
		if(r[i] == 0 && check(i)) now = i;
	}
	for(int i = n; i >= 1; i--) {
		a[now] = i;
		r[now] = -1;
		s.erase(now);
		for(int j = 1; j < k; j++) {
			int id = (now - j + n) % n;
			r[id]--;
			if(r[id] == 0) s.in(id);
		}
		for(int j = 1; j < k; j++) {
			int id = (now - j + n) % n;
			if(r[id] == 0 && check(id)) {
				now = id;
				break;
			}
			id = (now + j) % n;
			if(r[id] == 0 && check(id)) {
				now = id;
				break;
			}
		}
	}
}

int compare_plants(int x, int y) {
	if(a[x] > a[y]) return 1;
	else return -1;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 340 KB Output is correct
7 Correct 201 ms 3084 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 7 ms 364 KB Output is correct
10 Correct 180 ms 3096 KB Output is correct
11 Correct 95 ms 3168 KB Output is correct
12 Correct 104 ms 3220 KB Output is correct
13 Correct 205 ms 3132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 340 KB Output is correct
7 Correct 201 ms 3084 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 7 ms 364 KB Output is correct
10 Correct 180 ms 3096 KB Output is correct
11 Correct 95 ms 3168 KB Output is correct
12 Correct 104 ms 3220 KB Output is correct
13 Correct 205 ms 3132 KB Output is correct
14 Correct 1799 ms 3260 KB Output is correct
15 Execution timed out 4049 ms 4940 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 280 KB Output is correct
3 Incorrect 40 ms 3260 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -