Submission #773583

# Submission time Handle Problem Language Result Execution time Memory
773583 2023-07-05T06:58:33 Z loctildore Gondola (IOI14_gondola) C++14
100 / 100
16 ms 2216 KB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
// trans rights
#define ll long long
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x), end(x)
#define MOD 1000000009

int valid(int n, int inputSeq[])
{
    int tmp = -1;
    set<int> st;
    for (int i = 0; i < n; i++) {
        if (inputSeq[i] <= n) {
            int cur = (inputSeq[i] - i + n) % n;
            if (tmp == -1) tmp = cur;
            if (tmp != cur) return 0;
        }
        else {
            if (st.find(inputSeq[i]) != st.end()) return 0;
            st.insert(inputSeq[i]);
        }
    }
    return 1;
}

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

int ori[100069];
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    int offst = 1;
    pair<int,int> maxi = {0, -1};
    for (int i = 0; i < n; i++) {
        if (gondolaSeq[i] <= n) {
            offst = gondolaSeq[i] - i;
        }
        maxi = max(maxi, {gondolaSeq[i], i});
    }
    for (int i = 0; i < n; i++) {
        ori[i] = (i + offst + n) % n;
        if (ori[i] == 0) ori[i] = n;
    }
    int l = maxi.f - n;
    for (int i = 0; i < l; i++) {
        replacementSeq[i] = -1;
    }
    for (int i = 0; i < n; i++) {
        if (gondolaSeq[i] > n && gondolaSeq[i] != maxi.f) {
            replacementSeq[gondolaSeq[i] - n - 1] = ori[i];
        }
    }
    int cur = ori[maxi.s];
    for (int i = 0; i < l; i++) {
        if (~replacementSeq[i]) continue;
        replacementSeq[i] = cur;
        cur = i + n + 1;
    }
    return l;
}

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

ll pw(int x, ll y) {
    if (y == 0) return 1;
    if (y % 2) return (x * pw(x, y - 1)) % MOD;
    ll tmp = pw(x, y / 2);
    return (tmp * tmp) % MOD;
}

int countReplacement(int n, int inputSeq[])
{
    vector<int> vctr= {n};
    ll rtn = n;
    for (int i = 0; i < n; i++) {
        if (inputSeq[i] > n) vctr.push_back(inputSeq[i]);
        else rtn = 1;
    }
    sort(all(vctr));
    int tmp = vctr.size();
    for (int i = 1; i < vctr.size(); i++) {
        rtn = (rtn * pw(tmp - i, vctr[i] - vctr[i - 1] - 1)) % MOD;
    }
    return rtn;
}

Compilation message

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:84:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |     for (int i = 1; i < vctr.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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 0 ms 256 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 10 ms 596 KB Output is correct
8 Correct 5 ms 548 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 6 ms 596 KB Output is correct
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 6 ms 612 KB Output is correct
8 Correct 6 ms 580 KB Output is correct
9 Correct 4 ms 396 KB Output is correct
10 Correct 6 ms 596 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 3 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 8 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 224 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 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory 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
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 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 6 ms 836 KB Output is correct
12 Correct 7 ms 980 KB Output is correct
13 Correct 8 ms 1192 KB Output is correct
14 Correct 11 ms 848 KB Output is correct
15 Correct 14 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 11 ms 980 KB Output is correct
10 Correct 8 ms 1236 KB Output is correct
11 Correct 4 ms 708 KB Output is correct
12 Correct 4 ms 812 KB Output is correct
13 Correct 1 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 0 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 10 ms 980 KB Output is correct
10 Correct 9 ms 1236 KB Output is correct
11 Correct 5 ms 724 KB Output is correct
12 Correct 4 ms 724 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 16 ms 2108 KB Output is correct
15 Correct 16 ms 2216 KB Output is correct
16 Correct 5 ms 724 KB Output is correct
17 Correct 11 ms 1580 KB Output is correct
18 Correct 10 ms 1096 KB Output is correct