Submission #347169

# Submission time Handle Problem Language Result Execution time Memory
347169 2021-01-12T07:06:30 Z 79brue Gondola (IOI14_gondola) C++14
100 / 100
31 ms 2664 KB
#include <bits/stdc++.h>
#include "gondola.h"

using namespace std;

typedef long long ll;

int valid(int n, int arr[]){
    vector<int> chk(250001);
    auto it = min_element(arr, arr+n);
    rotate(arr, it, arr+n);

    for(int i=0; i<n; i++){
        if(chk[arr[i]]) return 0;
        chk[arr[i]] = 1;
        if(arr[i] <= n && i != arr[i]-arr[0]) return 0;
    }

    return 1;
}

int replacement(int n, int arr[], int ret[]){
    auto it = min_element(arr, arr+n);
    int minV = *it, minL = it-arr;
    rotate(arr, arr+(minL - (minV%n) + 1 + n)%n, arr+n);

    vector<int> idx(250001);
    for(int i=0; i<n; i++){
        idx[arr[i]] = i+1;
    }
    int tmp = *max_element(arr, arr+n);

    for(int i=n+1; i<=tmp; i++){
        if(idx[i]) ret[i-n-1] = idx[i];
        else ret[i-n-1] = idx[tmp], idx[tmp] = i;
    }
    return tmp-n;
}

const ll MOD = 1000000009;
ll mpow(ll x, ll y){
    if(!y) return 1;
    if(y&1) return mpow(x, y-1)*x%MOD;
    ll tmp = mpow(x, y/2);
    return tmp*tmp%MOD;
}

int countReplacement(int n, int arr[]){
    auto it = min_element(arr, arr+n);
    rotate(arr, it, arr+n);
    for(int i=0; i<n; i++) if(arr[i] <= n && i != arr[i]-arr[0]) return 0;
    vector<int> tmpVec (arr, arr+n);
    sort(tmpVec.begin(), tmpVec.end());
    for(int i=1; i<n; i++) if(tmpVec[i-1] == tmpVec[i]) return 0;

    ll ans = (tmpVec[0] > n) ? n : 1;

    vector<int> vec (1, n);
    for(int i=0; i<n; i++) if(arr[i] > n) vec.push_back(arr[i]);
    sort(vec.begin(), vec.end());

    for(int i=1; i<(int)vec.size(); i++){
        ans *= mpow((int)vec.size() - i, vec[i] - vec[i-1] - 1);
        ans %= MOD;
    }
    return int(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1260 KB Output is correct
2 Correct 1 ms 1260 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 1 ms 1260 KB Output is correct
5 Correct 1 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1260 KB Output is correct
2 Correct 1 ms 1260 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 1 ms 1260 KB Output is correct
5 Correct 2 ms 1260 KB Output is correct
6 Correct 6 ms 1644 KB Output is correct
7 Correct 16 ms 2156 KB Output is correct
8 Correct 9 ms 2028 KB Output is correct
9 Correct 4 ms 1516 KB Output is correct
10 Correct 11 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1260 KB Output is correct
2 Correct 1 ms 1260 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 1 ms 1280 KB Output is correct
5 Correct 1 ms 1260 KB Output is correct
6 Correct 6 ms 1644 KB Output is correct
7 Correct 11 ms 2156 KB Output is correct
8 Correct 10 ms 2028 KB Output is correct
9 Correct 4 ms 1516 KB Output is correct
10 Correct 11 ms 2156 KB Output is correct
11 Correct 1 ms 1260 KB Output is correct
12 Correct 1 ms 1260 KB Output is correct
13 Correct 6 ms 1644 KB Output is correct
14 Correct 2 ms 1260 KB Output is correct
15 Correct 15 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1260 KB Output is correct
2 Correct 1 ms 1260 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 1 ms 1260 KB Output is correct
5 Correct 2 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1260 KB Output is correct
2 Correct 2 ms 1260 KB Output is correct
3 Correct 2 ms 1388 KB Output is correct
4 Correct 1 ms 1260 KB Output is correct
5 Correct 1 ms 1260 KB Output is correct
6 Correct 1 ms 1260 KB Output is correct
7 Correct 1 ms 1260 KB Output is correct
8 Correct 2 ms 1260 KB Output is correct
9 Correct 2 ms 1260 KB Output is correct
10 Correct 3 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1260 KB Output is correct
2 Correct 1 ms 1260 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 1 ms 1260 KB Output is correct
5 Correct 1 ms 1260 KB Output is correct
6 Correct 1 ms 1260 KB Output is correct
7 Correct 1 ms 1260 KB Output is correct
8 Correct 2 ms 1260 KB Output is correct
9 Correct 2 ms 1260 KB Output is correct
10 Correct 2 ms 1260 KB Output is correct
11 Correct 10 ms 2028 KB Output is correct
12 Correct 11 ms 2156 KB Output is correct
13 Correct 14 ms 1900 KB Output is correct
14 Correct 10 ms 2028 KB Output is correct
15 Correct 24 ms 2200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 21 ms 1772 KB Output is correct
10 Correct 17 ms 1516 KB Output is correct
11 Correct 7 ms 876 KB Output is correct
12 Correct 8 ms 1024 KB Output is correct
13 Correct 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 21 ms 1772 KB Output is correct
10 Correct 17 ms 1516 KB Output is correct
11 Correct 7 ms 876 KB Output is correct
12 Correct 8 ms 900 KB Output is correct
13 Correct 3 ms 492 KB Output is correct
14 Correct 27 ms 2408 KB Output is correct
15 Correct 31 ms 2664 KB Output is correct
16 Correct 6 ms 876 KB Output is correct
17 Correct 21 ms 1900 KB Output is correct
18 Correct 12 ms 1388 KB Output is correct