답안 #995221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995221 2024-06-08T16:27:12 Z alex_2008 식물 비교 (IOI20_plants) C++14
0 / 100
1 ms 2396 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 - 1];
	}
	for (int i = n; i >= 1; i--) {
		for (int j = 1; j <= n; j++) {
			if (r[j] != 0) continue;
			bool ch = true;
			for (int l = j + k; l <= n; l++) {
				if (r[l] == 0) {
					ch = false;
				}
			}
			for (int l = 1; l < j; l++) {
				if (l + (k - 1) < j) continue;
				if (r[l] == 0) {
					ch = false;
				}
			}
			if (ch) {
				r[j] = -1;
				perm[j] = i;
				for (int l = max(1, (j - k + 1)); l < j; l++) {
					r[l]--;
				}
				if ((j - k + 1) < 1) {
					int mnac = (k - 1) - (j - 1);
					for (int l = n; l > n - mnac; l--) {
						r[l]--;
					}
				}
				break;
			}
		}
	}
}
int compare_plants(int x, int y) {
	if (perm[x] > perm[y]) return 1;
	return -1;
}
/*
int main() {
	init(3, { 2, 1, 0, 2, 1 });
	for (int i = 1; i <= 5; i++) {
		cout << perm[i] << " ";
	}
}
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -