답안 #400225

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
400225 2021-05-07T17:32:12 Z faresbasbs 식물 비교 (IOI20_plants) C++14
14 / 100
479 ms 7716 KB
#include <bits/stdc++.h>
#include "plants.h"
using namespace std;
bool seen[5001];
int val[5001];

void init(int k , vector<int> r){
	int n = r.size() , cnt = 0;;
	for(int i = 0 ; i < n ; i += 1){
		int pos;
		for(int j = 0 ; j < n ; j += 1){
			if(seen[j] || r[j]){
				continue;
			}
			pos = j;
		}
		int f = -1;
		for(int j = 1 ; j < k ; j += 1){
			if(seen[(pos-j+n)%n] || r[(pos-j+n)%n]){
				continue;
			}
			f = (pos-j+n)%n;
		}
		if(f != -1){
			pos = f;
		}
		val[pos] = cnt++;
		seen[pos] = 1;
		for(int j = 1 ; j < k ; j += 1){
			if(seen[(pos-j+n)%n]){
				continue;
			}
			r[(pos-j+n)%n] -= 1;
		}
	}
}

int compare_plants(int x, int y){
	if(val[x] < val[y]){
		return 1;
	}
	return -1;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:28:13: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |   seen[pos] = 1;
      |   ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 15 ms 416 KB Output is correct
7 Correct 416 ms 4992 KB Output is correct
8 Correct 3 ms 332 KB Output is correct
9 Correct 15 ms 416 KB Output is correct
10 Correct 435 ms 4992 KB Output is correct
11 Correct 220 ms 4996 KB Output is correct
12 Correct 236 ms 5188 KB Output is correct
13 Correct 479 ms 4984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 15 ms 416 KB Output is correct
7 Correct 416 ms 4992 KB Output is correct
8 Correct 3 ms 332 KB Output is correct
9 Correct 15 ms 416 KB Output is correct
10 Correct 435 ms 4992 KB Output is correct
11 Correct 220 ms 4996 KB Output is correct
12 Correct 236 ms 5188 KB Output is correct
13 Correct 479 ms 4984 KB Output is correct
14 Runtime error 49 ms 7716 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 71 ms 3184 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -