답안 #16214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16214 2015-08-18T04:52:29 Z CodingBug 곤돌라 (IOI14_gondola) C++
65 / 100
31 ms 2968 KB
#include "gondola.h"
#include <vector>
#include <stdio.h>
#include <algorithm>
#define LMT 1000000009
using namespace std;

int valid(int n, int inputSeq[])
{
    int i,p;
    for(i=0;i<n;i++) if(inputSeq[i]<=n) break;
    p=inputSeq[i];
    for(;i<n;i++,p++) if(inputSeq[i]<=n && inputSeq[i]!=(p-1)%n+1) return 0;
    return 1;
}

//----------------------

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    int i,p,l;
    vector<pair<int,int> > v;
    for(i=0;i<n;i++) if(gondolaSeq[i]>n) v.push_back(make_pair(gondolaSeq[i],i));
    sort(v.begin(),v.end());
    for(i=0;i<n;i++) if(gondolaSeq[i]<=n) break;
    if(i==n) gondolaSeq[i=0]=1;
    for(p=1;p<n;p++) gondolaSeq[(p+i)%n]=(gondolaSeq[i]+p-1)%n+1;
    for(i=n+1,p=0,l=0;p<v.size();i++){
        replacementSeq[l++]=gondolaSeq[v[p].second];
        gondolaSeq[v[p].second]=i;
        if(v[p].first==i) p++;
    }
    return l;
}

//----------------------

int mpow(int x,int y){
    if(!y) return 1;
    int k=mpow(x,y/2);
    if(y&1) return (long long)((long long)k*k%LMT)*x%LMT;
    else return (long long)k*k%LMT;
}

int countReplacement(int n, int inputSeq[])
{
    if(!valid(n,inputSeq)) return 0;
    int i,p,s=1;
    vector<int> v;
    for(i=0;i<n;i++) if(inputSeq[i]>n) v.push_back(inputSeq[i]);
    v.push_back(n);
    sort(v.begin(),v.end());
    for(i=1;i<v.size();i++) s=(long long)s*mpow(((int)v.size()-i),(v[i]-v[i-1]-1))%LMT;
    return s;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
4 Correct 0 ms 2580 KB Output is correct
5 Correct 0 ms 2580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
4 Correct 0 ms 2580 KB Output is correct
5 Correct 0 ms 2580 KB Output is correct
6 Correct 0 ms 2580 KB Output is correct
7 Correct 0 ms 2580 KB Output is correct
8 Correct 0 ms 2580 KB Output is correct
9 Correct 3 ms 2580 KB Output is correct
10 Correct 8 ms 2580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
4 Correct 0 ms 2580 KB Output is correct
5 Correct 0 ms 2580 KB Output is correct
6 Correct 0 ms 2580 KB Output is correct
7 Correct 8 ms 2580 KB Output is correct
8 Correct 11 ms 2580 KB Output is correct
9 Correct 0 ms 2580 KB Output is correct
10 Correct 0 ms 2580 KB Output is correct
11 Incorrect 0 ms 2580 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
4 Correct 0 ms 2580 KB Output is correct
5 Correct 0 ms 2580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
4 Correct 0 ms 2580 KB Output is correct
5 Correct 0 ms 2580 KB Output is correct
6 Correct 0 ms 2580 KB Output is correct
7 Correct 0 ms 2580 KB Output is correct
8 Correct 1 ms 2580 KB Output is correct
9 Correct 0 ms 2580 KB Output is correct
10 Correct 0 ms 2580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
4 Correct 0 ms 2580 KB Output is correct
5 Correct 0 ms 2580 KB Output is correct
6 Correct 0 ms 2580 KB Output is correct
7 Correct 0 ms 2580 KB Output is correct
8 Correct 0 ms 2580 KB Output is correct
9 Correct 0 ms 2580 KB Output is correct
10 Correct 0 ms 2580 KB Output is correct
11 Correct 16 ms 2580 KB Output is correct
12 Correct 0 ms 2580 KB Output is correct
13 Correct 14 ms 2968 KB Output is correct
14 Correct 16 ms 2580 KB Output is correct
15 Correct 31 ms 2968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
4 Correct 0 ms 2580 KB Output is correct
5 Correct 0 ms 2580 KB Output is correct
6 Correct 0 ms 2580 KB Output is correct
7 Correct 0 ms 2580 KB Output is correct
8 Correct 0 ms 2580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
4 Correct 0 ms 2580 KB Output is correct
5 Correct 0 ms 2580 KB Output is correct
6 Correct 0 ms 2580 KB Output is correct
7 Correct 0 ms 2580 KB Output is correct
8 Correct 0 ms 2580 KB Output is correct
9 Correct 22 ms 2968 KB Output is correct
10 Correct 15 ms 2968 KB Output is correct
11 Correct 6 ms 2708 KB Output is correct
12 Correct 14 ms 2708 KB Output is correct
13 Incorrect 0 ms 2580 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2580 KB Output is correct
2 Correct 0 ms 2580 KB Output is correct
3 Correct 0 ms 2580 KB Output is correct
4 Correct 0 ms 2580 KB Output is correct
5 Correct 0 ms 2580 KB Output is correct
6 Correct 0 ms 2580 KB Output is correct
7 Correct 0 ms 2580 KB Output is correct
8 Correct 0 ms 2580 KB Output is correct
9 Correct 18 ms 2968 KB Output is correct
10 Correct 18 ms 2968 KB Output is correct
11 Correct 9 ms 2708 KB Output is correct
12 Correct 9 ms 2708 KB Output is correct
13 Incorrect 0 ms 2580 KB Output isn't correct
14 Halted 0 ms 0 KB -