Submission #995210

# Submission time Handle Problem Language Result Execution time Memory
995210 2024-06-08T16:06:48 Z alex_2008 Comparing Plants (IOI20_plants) C++14
0 / 100
4 ms 4700 KB
#include "plants.h"
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const int N = 2e5 + 10;
int r[N], perm[N];
int val[N];
int n, k;
void init(int K, vector<int> R) {
	k = K;
	n = (int)R.size();
	for (int i = 1; i <= n; i++) {
		r[i] = R[i];
	}
	for (int i = n; i >= 1; i--) {
      	int j;
		for (j = 1; j <= n; j++) {
			bool ch = true;
			if (r[j] != (k - 1)) continue;
			for (int l = j + k; l <= n; l++) {
				if (r[l] == (k - 1)) {
					ch = false;
				}
			}
			for (int l = 1; l < i; l++) {
				if (r[l] == (k - 1)) {
					ch = false;
				}
			}
			if (ch) {
              	r[j] = -1;
				perm[j] = i;
				for (int l = max(1, (j - k + 1)); l < j; l++) {
					r[l]++;
				}
				if ((i - k + 1) < 1) {
					int mnac = (k - 1) - (j - 1);
					for (int l = n; l > n - mnac; l--) {
						r[l]--;
					}
				}
				break;
			}
		}
      	if (j > n) {
          throw "esim";
        }
	}
}
int compare_plants(int x, int y) {
	if (perm[x] > perm[y]) return 1;
	return -1;
}
/*
int main() {

}
*/
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4696 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4696 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4696 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4700 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -