Submission #825848

# Submission time Handle Problem Language Result Execution time Memory
825848 2023-08-15T08:48:26 Z amunduzbaev Comparing Plants (IOI20_plants) C++17
0 / 100
1 ms 468 KB
#include "plants.h"

#include "bits/stdc++.h"
using namespace std;

const int inf = 1e9;

vector<int> a;
int n;

void init(int k, vector<int> r) {
	
	n = r.size();
	a.resize(n);
	for(int i=n;i>0;i--){
		//~ for(int i=0;i<n;i++) cout<<r[i]<<" ";
		//~ cout<<"\n";
		int cnt = 0;
		for(int i=0;i<k - 1;i++) cnt += (r[i] == 0);
		int p = -1;
		for(int i=k - 1;;){
			if(!cnt && r[i] == 0){
				p = i;
				break;
			}
			
			cnt -= (r[(i + n - k + 1) % n] == 0);
			i = (i + 1) % n;
			if(i == k - 1) break;
		}
		
		//~ assert(~p);
		assert(a[p] == 0);
		//~ cout<<i<<endl;
		r[p] = inf;
		a[p] = i;
		for(int i=0;i<n;i++){
			if((i <= p && p < i + k) || (i <= p + n && p + n < i + k)){
				r[i]--;
			}
		}
	}
	
	//~ for(int i=0;i<n;i++) cout<<a[i]<<" ";
	//~ cout<<"\n";
	
	return;
}

int compare_plants(int x, int y) {
	if(a[x] > a[y]) return 1;
	if(a[x] < a[y]) return -1;
	
	return 0;
}
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Runtime error 1 ms 340 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Runtime error 1 ms 340 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 340 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -