답안 #31170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31170 2017-08-12T08:34:53 Z cscandkswon 곤돌라 (IOI14_gondola) C++14
90 / 100
1000 ms 4952 KB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100000;
const long long MOD=1000000009;   

int init[MAXN];
     
void settinginit(int n, int seq[]){
 	int i, x=-1;
   	for(i=0; i<n; i++)if(seq[i]<=n){
   		x=(i-seq[i]+1+n)%n;
   		break;
   	}
   	if(x==-1) x=0;
   	for(i=0; i<n; i++, x=(x+1)%n) init[x]=i+1;
}
     
int valid(int n, int inputSeq[]){
    int i;
   	settinginit(n, inputSeq);
   	for(i=0; i<n; i++) if(inputSeq[i]<=n&&inputSeq[i]!=init[i]) return 0;
	sort(inputSeq, inputSeq+n);
    for(i=1; i<n; i++) if(inputSeq[i-1]==inputSeq[i]) return 0;
    return 1;
}
     
pair<int, int> rep[MAXN];
     
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
  	int i, length=0, change=0, last=n+1;
   	settinginit(n, gondolaSeq);
   	for(i=0; i<n; i++) if(gondolaSeq[i]!=init[i])
   		rep[change].first=gondolaSeq[i], rep[change++].second=i;
   	sort(rep, rep+change);
   	for(i=0; i<change; i++){	
   		replacementSeq[length++]=init[rep[i].second];
   		for(; last<rep[i].first; last++) replacementSeq[length++]=last;
   		last=rep[i].first+1;
   	}
   	return length;
}
     
int plc[MAXN];

int getpow(int a, int b){
	if(b==0) return 1;
	if(b==1) return a;
	return (long long)getpow(a, b/2)*getpow(a, (b+1)/2)%MOD;
}

int countReplacement(int n, int inputSeq[]){
	long long count=1;
	int i, change=0, last=n+1, o=1;
	if(valid(n, inputSeq)==0) return 0;
	if(inputSeq[0]>n) o=n;
	for(i=0; i<n; i++) if(inputSeq[i]>=n)
		plc[change++]=inputSeq[i];
	sort(plc, plc+change);
	for(i=0; i<change; i++){
		count=count*getpow((change-i), (plc[i]-last))%MOD;
		last=plc[i]+1;
	}
	return count*o%MOD;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 0 ms 4952 KB Output is correct
5 Correct 0 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 0 ms 4952 KB Output is correct
5 Correct 0 ms 4952 KB Output is correct
6 Correct 9 ms 4952 KB Output is correct
7 Correct 9 ms 4952 KB Output is correct
8 Correct 13 ms 4952 KB Output is correct
9 Correct 3 ms 4952 KB Output is correct
10 Correct 19 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 0 ms 4952 KB Output is correct
5 Correct 0 ms 4952 KB Output is correct
6 Correct 9 ms 4952 KB Output is correct
7 Correct 16 ms 4952 KB Output is correct
8 Correct 9 ms 4952 KB Output is correct
9 Correct 6 ms 4952 KB Output is correct
10 Correct 19 ms 4952 KB Output is correct
11 Correct 0 ms 4952 KB Output is correct
12 Correct 0 ms 4952 KB Output is correct
13 Correct 9 ms 4952 KB Output is correct
14 Correct 0 ms 4952 KB Output is correct
15 Correct 13 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 0 ms 4952 KB Output is correct
5 Correct 0 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 0 ms 4952 KB Output is correct
5 Correct 0 ms 4952 KB Output is correct
6 Correct 0 ms 4952 KB Output is correct
7 Correct 0 ms 4952 KB Output is correct
8 Correct 0 ms 4952 KB Output is correct
9 Correct 0 ms 4952 KB Output is correct
10 Correct 0 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 0 ms 4952 KB Output is correct
5 Correct 0 ms 4952 KB Output is correct
6 Correct 0 ms 4952 KB Output is correct
7 Correct 0 ms 4952 KB Output is correct
8 Correct 0 ms 4952 KB Output is correct
9 Correct 0 ms 4952 KB Output is correct
10 Correct 0 ms 4952 KB Output is correct
11 Correct 9 ms 4952 KB Output is correct
12 Correct 13 ms 4952 KB Output is correct
13 Correct 19 ms 4952 KB Output is correct
14 Correct 9 ms 4952 KB Output is correct
15 Correct 33 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 0 ms 4952 KB Output is correct
5 Correct 0 ms 4952 KB Output is correct
6 Correct 0 ms 4952 KB Output is correct
7 Correct 0 ms 4952 KB Output is correct
8 Correct 0 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 0 ms 4952 KB Output is correct
5 Correct 0 ms 4952 KB Output is correct
6 Correct 0 ms 4952 KB Output is correct
7 Correct 0 ms 4952 KB Output is correct
8 Correct 0 ms 4952 KB Output is correct
9 Correct 13 ms 4952 KB Output is correct
10 Correct 16 ms 4952 KB Output is correct
11 Correct 9 ms 4952 KB Output is correct
12 Correct 6 ms 4952 KB Output is correct
13 Correct 3 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4952 KB Output is correct
2 Correct 0 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 0 ms 4952 KB Output is correct
5 Correct 0 ms 4952 KB Output is correct
6 Correct 0 ms 4952 KB Output is correct
7 Correct 0 ms 4952 KB Output is correct
8 Correct 0 ms 4952 KB Output is correct
9 Correct 23 ms 4952 KB Output is correct
10 Correct 16 ms 4952 KB Output is correct
11 Correct 6 ms 4952 KB Output is correct
12 Correct 6 ms 4952 KB Output is correct
13 Correct 3 ms 4952 KB Output is correct
14 Execution timed out 1000 ms 4952 KB Execution timed out
15 Halted 0 ms 0 KB -