답안 #773565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773565 2023-07-05T06:52:54 Z loctildore 곤돌라 (IOI14_gondola) C++14
75 / 100
15 ms 2200 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, int y) {
    if (y == 0) return 1;
    if (y % 2) return x * pw(x, y - 1);
    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++) {
      |                     ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 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 212 KB Output is correct
6 Correct 3 ms 468 KB Output is correct
7 Correct 7 ms 700 KB Output is correct
8 Correct 6 ms 724 KB Output is correct
9 Correct 2 ms 432 KB Output is correct
10 Correct 7 ms 724 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 0 ms 312 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 3 ms 572 KB Output is correct
7 Correct 7 ms 700 KB Output is correct
8 Correct 6 ms 704 KB Output is correct
9 Correct 2 ms 452 KB Output is correct
10 Correct 7 ms 724 KB Output is correct
11 Correct 0 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 1 ms 212 KB Output is correct
15 Correct 7 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 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
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 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 1 ms 340 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 7 ms 972 KB Output is correct
12 Correct 8 ms 1156 KB Output is correct
13 Correct 9 ms 1336 KB Output is correct
14 Correct 7 ms 1052 KB Output is correct
15 Correct 15 ms 2200 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 0 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 312 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 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 1 ms 300 KB Output is correct
9 Incorrect 10 ms 1364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 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 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 316 KB Output is correct
9 Incorrect 10 ms 1480 KB Output isn't correct
10 Halted 0 ms 0 KB -