답안 #400224

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
400224 2021-05-07T17:30:54 Z faresbasbs 식물 비교 (IOI20_plants) C++14
0 / 100
70 ms 3048 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;
		}
		for(int j = 1 ; j < k ; j += 1){
			if(seen[(pos-j+n)%n] || r[(pos-j+n)%n]){
				continue;
			}
			pos = (pos-j+n)%n;
			break;
		}
		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(!seen[x] || !seen[y]){
		return 0;
	}
	if(val[x] < val[y]){
		return 1;
	}
	return -1;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:25:13: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |   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 Incorrect 1 ms 204 KB Output isn't correct
6 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 Incorrect 1 ms 204 KB Output isn't correct
6 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 70 ms 3048 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 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 -