답안 #1065664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1065664 2024-08-19T10:37:45 Z andrei_iorgulescu 곤돌라 (IOI14_gondola) C++14
55 / 100
25 ms 10840 KB
#include <bits/stdc++.h>
#include "gondola.h"
#warning That's not FB, that's my FB

using namespace std;

int valid(int n, int inputSeq[])
{
    for (int i = 0; i < n; i++)
        inputSeq[i]--;
    int shift = -1;
    set<int> ele;
    for (int i = 0; i < n; i++)
        ele.insert(inputSeq[i]);
    if (ele.size() != n)
        return 0;
    for (int i = 0; i < n; i++)
    {
        if (inputSeq[i] < n)
        {
            int cur_shift = (n + inputSeq[i] - i) % n;
            if (shift == -1)
                shift = cur_shift;
            else if (shift != cur_shift)
                return 0;
        }
    }
    return 1;
}

int replacement(int n, int gondolaSequence[], int replacementSeq[])
{
    for (int i = 0; i < n; i++)
        gondolaSequence[i]--;
    int mxe = 0;
    for (int i = 0; i < n; i++)
        mxe = max(mxe, gondolaSequence[i]);
    vector<int> pos(mxe + 5), ans(mxe + 5);
    for (int i = 0; i <= mxe; i++)
        pos[i] = -1;
    for (int i = 0; i < n; i++)
        pos[gondolaSequence[i]] = i;
    set<int> spatii;
    for (int i = mxe; i >= 0; i--)
    {
        if (pos[i] == -1)
            ans[i] = *spatii.begin();
        else
            ans[i] = pos[i], spatii.insert(pos[i]);
    }
    int shift = 0;
    for (int i = 0; i < n; i++)
    {
        if (gondolaSequence[i] < n)
        {
            shift = (n + gondolaSequence[i] - i) % n;
        }
    }
    vector<vector<int>> lol(n);
    for (int i = 0; i < n; i++)
        lol[i].push_back((i + shift) % n);
    for (int i = n; i <= mxe; i++)
        lol[ans[i]].push_back(i);
    vector<int> cur(n);
    for (int i = n; i <= mxe; i++)
    {
        replacementSeq[i - n] = lol[ans[i]][cur[ans[i]]];
        cur[ans[i]]++;
    }
    for (int i = 0; i <= mxe - n; i++)
        replacementSeq[i]++;
    return mxe - n + 1;
}

int countReplacement(int n, int inputSeq[])
{
    return -1;
}

Compilation message

gondola.cpp:3:2: warning: #warning That's not FB, that's my FB [-Wcpp]
    3 | #warning That's not FB, that's my FB
      |  ^~~~~~~
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:15:20: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     if (ele.size() != n)
      |         ~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 2272 KB Output is correct
7 Correct 19 ms 3676 KB Output is correct
8 Correct 14 ms 3844 KB Output is correct
9 Correct 4 ms 1372 KB Output is correct
10 Correct 18 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 2140 KB Output is correct
7 Correct 20 ms 3720 KB Output is correct
8 Correct 14 ms 3928 KB Output is correct
9 Correct 4 ms 1372 KB Output is correct
10 Correct 18 ms 4444 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 440 KB Output is correct
13 Correct 12 ms 2396 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 25 ms 5324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 356 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 352 KB Output is correct
11 Correct 19 ms 9704 KB Output is correct
12 Correct 23 ms 10840 KB Output is correct
13 Correct 19 ms 5596 KB Output is correct
14 Correct 19 ms 9560 KB Output is correct
15 Correct 17 ms 5072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -