답안 #817379

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

vector<int> ans;
void init(int k, std::vector<int> r) {
	int n = r.size();
	ans.resize(n);
	for(int val = n - 1; val >= 0; val--){
		vector<int> a;
		for(int i = 0; i < n; i++){
			if(r[i] == 0){
				a.push_back(i);
			}
		}
		int bst = -1;
		for(int i = 0; i < a.size(); i++){
			int prv = (i - 1 + a.size()) % a.size();
			int d = (i == 0 ? a[i] + n - a[prv] : a[i] - a[prv]);
			if(d >= k){
				assert(bst == -1);
				bst = a[i];
			}
		}
		ans[bst] = val;
		r[bst] = 1e9;
		for(int i = 1; i < k; i++){
			int id = (bst - i + n) % n;
			r[id] = max(r[id] - 1, 0);
		}
	}
}

int compare_plants(int x, int y) {
	if(ans[x] > ans[y]) return 1;
	else return -1;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(int i = 0; i < a.size(); i++){
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 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 Runtime error 1 ms 340 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 312 KB Output is correct
7 Correct 188 ms 4996 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 8 ms 340 KB Output is correct
10 Correct 189 ms 4980 KB Output is correct
11 Correct 197 ms 5128 KB Output is correct
12 Correct 159 ms 5112 KB Output is correct
13 Correct 222 ms 4980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 312 KB Output is correct
7 Correct 188 ms 4996 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 8 ms 340 KB Output is correct
10 Correct 189 ms 4980 KB Output is correct
11 Correct 197 ms 5128 KB Output is correct
12 Correct 159 ms 5112 KB Output is correct
13 Correct 222 ms 4980 KB Output is correct
14 Correct 1921 ms 5600 KB Output is correct
15 Execution timed out 4070 ms 8628 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 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 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
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 Runtime error 1 ms 340 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -