답안 #835728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835728 2023-08-23T18:34:31 Z 7mody 곤돌라 (IOI14_gondola) C++17
65 / 100
51 ms 6732 KB
#include "gondola.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 250005;
const int mod=1e9+9;

ll power(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1) res=(1LL*res*a)%mod;
        a=(a*a)%mod;
        n>>=1;
    }
    return res;
}
 
map<int,int> mp;
 
int valid(int n, int p[]){
    int start=-1;
    for(int i=0;i<n;i++){
        if(mp[p[i]]) return 0;
        mp[p[i]]=1;
        if(p[i]<=n){
            int curr=(i-p[i]+n)%n;
            if(start==-1) start=curr; 
            else if(start!=curr) return 0;
        }
    }
    return 1;
}
 
// --------------------------------------------------------------

int replacement(int n, int p[], int res[]){
    int start=0;
    deque<int> arr(n);
    for(int i=0; i < n;i++){
        if(p[i]<=n) start=(i-p[i]+n)%n;
        arr[i]=p[i];
    }
    while(start){
        start--;
        int temp=arr.front();
        arr.pop_front();
        arr.push_back(temp);
    }
    vector<pair<int,int>> curr;
    for(int i=0; i < n;i++){
        if(arr[i]>n) curr.push_back({arr[i],i});
    }
    int size=0;
    sort(curr.begin(),curr.end());
    int del=n;
    for(auto [val,i] : curr){
        res[size++]=i+1;del++;
        while(del<val) res[size++]=del++;
    }
    return size;
}

// --------------------------------------------------------------
 
int countReplacement(int n, int p[]){
    if(!valid(n,p)) return 0;
    vector<int> arr;
    int res=1,a=n;
    for(int i=0;i<n;i++){
        if(p[i]<=n) a--;
        else arr.push_back(p[i]);
    }
    if(a==n) res=n;
    int pre=n;
    sort(arr.begin(),arr.end());
    for(int x:arr){
        res=ll(res)*power(a,x-pre-1)%mod;
        pre=x;
        a--;
    }
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 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 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 10 ms 2388 KB Output is correct
7 Correct 6 ms 1108 KB Output is correct
8 Correct 18 ms 4432 KB Output is correct
9 Correct 6 ms 1492 KB Output is correct
10 Correct 24 ms 4960 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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 432 KB Output is correct
6 Correct 10 ms 2388 KB Output is correct
7 Correct 7 ms 1108 KB Output is correct
8 Correct 18 ms 4308 KB Output is correct
9 Correct 6 ms 1492 KB Output is correct
10 Correct 23 ms 4948 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 6 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 212 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 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 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 32 ms 4812 KB Output is correct
10 Correct 26 ms 4072 KB Output is correct
11 Correct 10 ms 1748 KB Output is correct
12 Correct 11 ms 2004 KB Output is correct
13 Correct 3 ms 848 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 336 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 34 ms 4812 KB Output is correct
10 Correct 28 ms 4172 KB Output is correct
11 Correct 9 ms 1748 KB Output is correct
12 Correct 12 ms 2004 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 42 ms 6000 KB Output is correct
15 Correct 51 ms 6732 KB Output is correct
16 Correct 10 ms 1492 KB Output is correct
17 Correct 29 ms 4428 KB Output is correct
18 Correct 16 ms 2772 KB Output is correct