Submission #400223

# Submission time Handle Problem Language Result Execution time Memory
400223 2021-05-07T17:29:35 Z faresbasbs Comparing Plants (IOI20_plants) C++14
0 / 100
69 ms 4960 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(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;
      |   ~~~~~~~~~~^~~
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 208 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 208 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 69 ms 4960 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -