Submission #628179

# Submission time Handle Problem Language Result Execution time Memory
628179 2022-08-13T07:14:56 Z MilosMilutinovic Comparing Plants (IOI20_plants) C++14
0 / 100
34 ms 6992 KB
#include "plants.h"
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

int t[305];
bool rem[305], mark[305];
void init(int k, vector<int> r)
{
	int n = (int) r.size();
	int T = 0;
	rep(i, n) r[i] = k - 1 - r[i];
	while(1) {
		bool ok = false;
		rep(i, n) if(!rem[i]) ok = true;
		if(!ok) break;
		rep(i, n) mark[i] = false;
		rep(i, n) if(!rem[i]) {
			int cnt = 0;
			rep1(j, k - 1) if(!rem[(i + j) % n]) cnt ++;
			if(r[i] >= cnt) {
				rep1(j, k - 1) mark[(i + j) % n] = true;
			}
		}
		vector<int> vec;
		rep(i, n) if(!rem[i]) {
			int cnt = 0;
			rep1(j, k - 1) if(!rem[(i + j) % n]) cnt ++;
			if(r[i] >= cnt && !mark[i]) vec.push_back(i);
		}
		assert(!vec.empty());
		rep(id, vec.size()) {
			int i = vec[id];
			t[i] = T;
			rem[i] = true;
		}
		T ++;
	}
	return;
}

int compare_plants(int x, int y)
{
	return (t[x] == t[y] ? 0 : (t[x] < t[y] ? 1 : -1));
}

/*
4 3 2
0 1 1 2
0 2
1 2

4 2 2
0 1 0 1
0 3
1 3

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 4 ms 212 KB Output is correct
6 Runtime error 7 ms 576 KB Execution killed with signal 6
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 4 ms 212 KB Output is correct
6 Runtime error 7 ms 576 KB Execution killed with signal 6
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 34 ms 6992 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 304 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 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -