Submission #1360563

#TimeUsernameProblemLanguageResultExecution timeMemory
1360563takoshanavaGondola (IOI14_gondola)C++20
55 / 100
25 ms4984 KiB
#include "gondola.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fs first
#define sc second
using namespace std;

const ll N = 250005, MOD = 1e9 + 7;
int a[N];

ll binpow(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b % 2) res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2; 
    }
    return res;
}

int valid(int n, int inputSeq[]){
    set<int> sn;
    for(int i = 0; i < n; i++) a[i] = inputSeq[i];
    for(int i = 0; i < n; i++){
        if(sn.count(a[i])) return 0;
        sn.insert(a[i]);
    }

    int st = -1;
    for(int i = 0; i < n; i++){
        if(a[i] <= n){
            st = i;
            break;
        }
    }
    if(st == -1) return 1;
    int k = a[st];
    for(int i = 0; i < n; i++){
        int idx = (st + i) % n;
        if(a[idx] <= n){
            if(a[idx] != k) return 0;
        }
        k++;
        if(k > n) k = 1;
    }
    return 1;
}

int replacement(int n, int gondolaSeq[], int replacementSeq[]){
    for(int i = 0; i < n; i++) a[i] = gondolaSeq[i];
    int st = 0;
    while(st < n and a[st] > n) st++;
    int k = (st < n ? a[st] : 1);
    vector<pair<int, int>> v;
    for(int i = 0; i < n; i++){
        int idx = (st + i) % n;
        v.pb({a[idx], k});
        k++;
        if(k > n) k = 1;
    }
    sort(v.begin(), v.end());
    ll ls = n, r = 0;
    for(auto &p : v){
        while(p.sc != p.fs){
            replacementSeq[r] = p.sc;
            r++;
            p.sc = ++ls;
        }
    }
    return r;
}

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...