답안 #783188

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783188 2023-07-14T17:18:56 Z zsombor 곤돌라 (IOI14_gondola) C++17
60 / 100
10 ms 4576 KB
#include <iostream>
#include <vector>
#include "gondola.h"
using namespace std;
using ll = long long;

int valid(int n, int g[]) {
	vector <bool> volt(1e6 + 1, false);
	for (int i = 0; i < n; i++) {
		if (volt[g[i]]) return 0;
		volt[g[i]] = true;
	}
	int p = 0;
	for (int i = 0; i < n; i++) if (g[i] <= n) p = (g[i] - i + n) % n;
	for (int i = 0; i < n; i++) if (g[i] <= n && (g[i] - i + n) % n != p) return 0;
	return 1;
}

int replacement(int n, int g[], int r[]) {
	int p = 0, cnt = 0, mx = 0;
	vector <int> rev(1e6 + 1, -1);
	vector <int> cur(n, 0);
	for (int i = 0; i < n; i++) {
		if (g[i] <= n) { p = (g[i] - i + n) % n; cnt++; }
		mx = max(mx, g[i]);
		rev[g[i]] = i;
	}
	for (int i = 0; i < n; i++) cur[i] = (i + p) % n;
	cur[(n - p) % n] = n;
	for (int i = n + 1; i <= mx; i++) {
		if (rev[i] == -1) r[i - n - 1] = cur[rev[mx]];
		else r[i - n - 1] = cur[rev[i]];
	}
	return mx - n;
}

int countReplacement(int n, int g[]) {
	if (!valid(n, g)) return 0;
	int cnt = 0, mx = 0;
	ll ans = 1, MOD = 1e9 + 9;
	vector <int> rev(1e6 + 1, -1);
	for (int i = 0; i < n; i++) {
		if (g[i] <= n) cnt++;
		mx = max(mx, g[i]);
		rev[g[i]] = i;
	}
	if (cnt == 0) ans = n;
	for (int i = n + 1; i <= mx; i++) {
		if (rev[i] == -1) { ans *= (n - cnt); ans %= MOD; }
		else cnt++;
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 4 ms 560 KB Output is correct
7 Correct 7 ms 724 KB Output is correct
8 Correct 7 ms 708 KB Output is correct
9 Correct 3 ms 468 KB Output is correct
10 Correct 9 ms 668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 4 ms 468 KB Output is correct
7 Correct 7 ms 724 KB Output is correct
8 Correct 7 ms 596 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 8 ms 724 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 8 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Incorrect 2 ms 4180 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4160 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Incorrect 2 ms 4180 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4276 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 2 ms 4308 KB Output is correct
5 Correct 2 ms 4272 KB Output is correct
6 Correct 2 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 2 ms 4308 KB Output is correct
5 Correct 2 ms 4308 KB Output is correct
6 Correct 2 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4308 KB Output is correct
9 Correct 9 ms 4576 KB Output is correct
10 Correct 8 ms 4500 KB Output is correct
11 Correct 5 ms 4436 KB Output is correct
12 Correct 4 ms 4436 KB Output is correct
13 Correct 3 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 2 ms 4308 KB Output is correct
3 Correct 2 ms 4308 KB Output is correct
4 Correct 3 ms 4308 KB Output is correct
5 Correct 2 ms 4308 KB Output is correct
6 Correct 3 ms 4308 KB Output is correct
7 Correct 2 ms 4308 KB Output is correct
8 Correct 2 ms 4308 KB Output is correct
9 Correct 9 ms 4564 KB Output is correct
10 Correct 8 ms 4564 KB Output is correct
11 Correct 4 ms 4436 KB Output is correct
12 Correct 4 ms 4436 KB Output is correct
13 Correct 3 ms 4308 KB Output is correct
14 Runtime error 10 ms 2152 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -