답안 #120595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120595 2019-06-25T05:05:34 Z turbat 곤돌라 (IOI14_gondola) C++14
45 / 100
20 ms 2304 KB
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;
#define N 100005

int arr[N], mx, pos[10 * N], cnt, p;
bool note[3 * N];
long long mod = 1e9 + 9, ans = 1;
vector <int> vc;

int valid(int n, int inputSeq[]){
	for (int i = 0;i < n;i++){
		if (mx < inputSeq[i]){
			mx = inputSeq[i];
			p = i;
		}
		pos[inputSeq[i]] = i;
		if (note[inputSeq[i]]) return 0;
		note[inputSeq[i]] = 1;
	}
	for (int i = 0;i < n;i++)
		if (inputSeq[i] <= n){
			int now = inputSeq[i];
			arr[i] = now;
			for (int j = i + 1;j < n;j++){
				now++;
				if (now > n) now = 1;
				arr[j] = now;
			}
			for (int j = 0;j < i;j++){
				now++;
				if (now > n) now = 1;
				arr[j] = now;
			}
			break;
		}
	int ok = 1;
	for (int i = 0;i < n;i++)
		if (inputSeq[i] <= n && inputSeq[i] != arr[i])
			ok = 0;
	return ok;
}


int replacement(int n, int gondolaSeq[], int replacementSeq[]){
	if (!valid(n, gondolaSeq)) return 0;
	for (int i = 0;i < n;i++)
		if (gondolaSeq[i] > n)
			vc.push_back(gondolaSeq[i]);
	for (int i = n + 1;i <= mx;i++){
		if (!note[i]) {
			replacementSeq[i - n - 1] = arr[p];
			arr[p] = i;
		}
		else replacementSeq[i - n - 1] = arr[pos[i]];
	}
	return mx - n;
}

long long gg(long long x, int y){
	long long s = 1;
	while (y){
		if (y % 2) s = (s * x) % mod;
		x = (1ll * x * x) % mod;
		y /= 2;
	}
	return s;
}

int countReplacement(int n, int inputSeq[]){
	if (!valid(n, inputSeq)) return 0;
	for (int i = 0;i < n;i++)
		if (inputSeq[i] > n)
			vc.push_back(inputSeq[i]);
	sort(vc.begin(), vc.end());
	reverse(vc.begin(), vc.end());
	int bef = n;
	while (!vc.empty()){
		ans = (ans * gg(vc.size(), vc.back() - bef - 1)) % mod;
		bef = vc.back();
		vc.pop_back();
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 6 ms 1024 KB Output is correct
7 Correct 11 ms 1280 KB Output is correct
8 Correct 10 ms 1280 KB Output is correct
9 Correct 5 ms 768 KB Output is correct
10 Correct 11 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 6 ms 896 KB Output is correct
7 Correct 12 ms 1152 KB Output is correct
8 Correct 10 ms 1408 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 12 ms 1536 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 8 ms 1792 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 14 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 300 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Incorrect 2 ms 384 KB Integer 0 violates the range [1, 72]
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Incorrect 2 ms 384 KB Integer 0 violates the range [1, 72]
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 432 KB Output is correct
7 Correct 2 ms 320 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 20 ms 2304 KB Output is correct
10 Correct 15 ms 2004 KB Output is correct
11 Correct 9 ms 1664 KB Output is correct
12 Correct 10 ms 1536 KB Output is correct
13 Incorrect 4 ms 768 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 19 ms 2136 KB Output is correct
10 Correct 15 ms 1920 KB Output is correct
11 Correct 9 ms 1664 KB Output is correct
12 Correct 10 ms 1536 KB Output is correct
13 Incorrect 4 ms 640 KB Output isn't correct
14 Halted 0 ms 0 KB -