답안 #780920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780920 2023-07-12T14:39:47 Z vjudge1 곤돌라 (IOI14_gondola) C++17
55 / 100
15 ms 2384 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include "gondola.h"
#define MAX 250000
using namespace std;
int mark[MAX + 10];
vector <pair <int, int>> v;
int valid(int n, int inputSeq[])
{
    int posOrig = -1;
    for (int i = 0; i < n; i++)
    {
        if (mark[inputSeq[i]] == 1)
            return 0;
        if (inputSeq[i] <= n)
            posOrig = i;
        mark[inputSeq[i]] = 1;
    }
    if (posOrig == -1)
        return 1;
    int pos = posOrig;
    for (int i = 1; i <= n; i++)
    {
        if (inputSeq[pos] <= n && (inputSeq[pos] - inputSeq[posOrig] + n) % n != (pos - posOrig + n) % n)
            return 0;
        pos = (pos + 1) % n;
    }
    return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    int posOrig = -1;
    for (int i = 0; i < n; i++)
        if (gondolaSeq[i] <= n)
            posOrig = i;
    if (posOrig == -1)
        for (int i = 0; i < n; i++)
            v.push_back({gondolaSeq[i], i + 1});
    else
    {
        int pos = posOrig;
        int g = gondolaSeq[posOrig];
        for (int i = 1; i <= n; i++)
        {
            if (gondolaSeq[pos] > n)
                v.push_back({gondolaSeq[pos], g});
            pos = (pos + 1) % n;
            if (g == n - 1)
                g = n;
            else
                g = (g + 1) % n;
        }
    }
    sort(v.begin(), v.end());
    int l = 0, nn = n + 1;
    for (auto it : v)
    {
        replacementSeq[l] = it.second;
        l++;
        nn++;
        while (nn <= it.first)
        {
            replacementSeq[l] = nn - 1;
            l++;
            nn++;
        }
    }
    return l;
}
int countReplacement(int n, int inputSeq[])
{
    return -1;
}
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 1 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 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 3 ms 596 KB Output is correct
7 Correct 7 ms 876 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 7 ms 852 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 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 4 ms 596 KB Output is correct
7 Correct 6 ms 980 KB Output is correct
8 Correct 7 ms 852 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 7 ms 844 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 3 ms 1236 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 8 ms 980 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
4 Correct 0 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 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 0 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
# 결과 실행 시간 메모리 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 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 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 7 ms 596 KB Output is correct
12 Correct 7 ms 596 KB Output is correct
13 Correct 12 ms 1468 KB Output is correct
14 Correct 7 ms 596 KB Output is correct
15 Correct 15 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -