Submission #780885

# Submission time Handle Problem Language Result Execution time Memory
780885 2023-07-12T14:16:33 Z vjudge1 Gondola (IOI14_gondola) C++17
55 / 100
18 ms 2452 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 ind = gondolaSeq[posOrig];
        for (int i = 1; i <= n; i++)
        {
            if (gondolaSeq[pos] > n)
                v.push_back({gondolaSeq[pos], ind});
            pos = (pos + 1) % n;
            if (ind == n - 1)
                ind = (ind + 1) % n + n;
            else
                ind = (ind + 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;
}
# 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 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 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 4 ms 704 KB Output is correct
7 Correct 7 ms 1364 KB Output is correct
8 Correct 7 ms 1264 KB Output is correct
9 Correct 4 ms 596 KB Output is correct
10 Correct 7 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 4 ms 772 KB Output is correct
7 Correct 7 ms 1472 KB Output is correct
8 Correct 9 ms 1268 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 7 ms 1364 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 4 ms 1492 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 7 ms 1492 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 308 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 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 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 3 ms 312 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 304 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 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 1 ms 212 KB Output is correct
7 Correct 1 ms 308 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 980 KB Output is correct
12 Correct 8 ms 1088 KB Output is correct
13 Correct 16 ms 1616 KB Output is correct
14 Correct 6 ms 1020 KB Output is correct
15 Correct 18 ms 2452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB Integer -1 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -