답안 #576899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576899 2022-06-13T17:58:45 Z mosiashvililuka 곤돌라 (IOI14_gondola) C++14
100 / 100
69 ms 12872 KB
#include "gondola.h"
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,f[300009],pi,ee,WA,pas,mod=1000000009LL,p[300009];
map <long long, long long> fx;
int valid(int Nn, int inputSeq[])
{
    a=Nn;
    for(i=1; i<=a; i++) f[i]=inputSeq[i-1];
    set <int> SAE;
    for(i=1; i<=a; i++){
        if(f[i]<=a){
            c=f[i]-i+a*2;c%=a;
            SAE.insert(c);
        }
    }
    if(SAE.size()>=2) return 0;
    for(i=1; i<=a; i++){
        if(fx[f[i]]!=0) return 0;
        fx[f[i]]=1;
    }
    return 1;
}

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

int replacement(int Nn, int gondolaSeq[], int replacementSeq[])
{
    a=Nn;WA=1;
    for(i=1; i<=a; i++){
        f[i]=gondolaSeq[i-1];
    }
    for(i=1; i<=a; i++){
        if(f[i]>a){
            fx[f[i]]=i;
            if(e<f[i]){
                e=f[i];ee=i;
            }
        }else{
            WA=f[i]-i;
        }
    }
    for(i=1; i<=a; i++){
        f[i]=WA+i+a*3;f[i]%=a;
        if(f[i]==0) f[i]=a;
    }
    for(i=a+1; i<=e; i++){
        if(fx[i]==0){
            replacementSeq[pi]=/*ee*/f[ee];
            f[ee]=i;
        }else{
            c=fx[i];
            replacementSeq[pi]=/*fx[i]*/f[c];
        }
        pi++;
    }
    return pi;
}
long long xar(long long q, long long w){
    if(w==0) return 1LL;
    long long qw=xar(q,w/2);
    if(w%2==0) return (qw*qw)%mod; else return ((qw*qw)%mod*q)%mod;
}
//----------------------

int countReplacement(int Nn, int inputSeq[])
{
    a=Nn;
    for(i=1; i<=a; i++) f[i]=inputSeq[i-1];
    set <int> SAE;
    for(i=1; i<=a; i++){
        if(f[i]<=a){
            c=f[i]-i+a*2;c%=a;
            SAE.insert(c);
        }
    }
    if(SAE.size()>=2) return 0;
    for(i=1; i<=a; i++){
        if(fx[f[i]]!=0) return 0;
        fx[f[i]]=1;
    }
    pas=1;pi=1;
    p[pi]=a;
    for(i=1; i<=a; i++){
        if(f[i]>a){
            pi++;p[pi]=f[i];
        }
    }
    sort(p+1,p+pi+1);
    e=0;
    for(i=1; i<=a; i++) e=max(e,f[i]);
    if(e==a) return 1;
    /*for(i=a+1; i<=e; i++){
        if(fx[i]!=fx[i+1]){

        }else{
            pas*=fx[i];pas%=mod;
        }
    }*/
    for(i=1; i<pi; i++){
        d=p[i+1]-p[i]-1;
        pas*=xar(pi-i,d);pas%=mod;
    }
    zx=0;
    for(i=1; i<=a; i++) if(f[i]<=a) zx++;
    if(zx==0){
        pas*=a;pas%=mod;
    }
    return pas;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 16 ms 3276 KB Output is correct
7 Correct 23 ms 2900 KB Output is correct
8 Correct 27 ms 5856 KB Output is correct
9 Correct 9 ms 2140 KB Output is correct
10 Correct 33 ms 6676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 13 ms 3228 KB Output is correct
7 Correct 20 ms 2924 KB Output is correct
8 Correct 27 ms 5784 KB Output is correct
9 Correct 8 ms 2096 KB Output is correct
10 Correct 39 ms 6712 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 268 KB Output is correct
13 Correct 4 ms 852 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 18 ms 3024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 3 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 9 ms 1468 KB Output is correct
12 Correct 8 ms 1408 KB Output is correct
13 Correct 27 ms 5880 KB Output is correct
14 Correct 8 ms 1324 KB Output is correct
15 Correct 51 ms 12872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 42 ms 6436 KB Output is correct
10 Correct 32 ms 5308 KB Output is correct
11 Correct 11 ms 2268 KB Output is correct
12 Correct 16 ms 2568 KB Output is correct
13 Correct 3 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 49 ms 6356 KB Output is correct
10 Correct 30 ms 5324 KB Output is correct
11 Correct 11 ms 2268 KB Output is correct
12 Correct 14 ms 2624 KB Output is correct
13 Correct 4 ms 828 KB Output is correct
14 Correct 51 ms 7352 KB Output is correct
15 Correct 69 ms 8876 KB Output is correct
16 Correct 9 ms 1876 KB Output is correct
17 Correct 41 ms 6084 KB Output is correct
18 Correct 20 ms 3496 KB Output is correct