답안 #281566

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
281566 2020-08-23T08:09:27 Z SamAnd 곤돌라 (IOI14_gondola) C++17
20 / 100
47 ms 5496 KB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
const int N = 100005, M = 1000000009;

int n;
int a[N];

int valid(int n, int inputSeq[])
{
    ::n = n;
    for (int i = 0; i < n; ++i)
    {
        a[i] = inputSeq[i];
    }

    set<int> s;
    for (int i = 0; i < n; ++i)
        s.insert(a[i]);
    if (sz(s) != n)
        return 0;

    int minu = M;
    int mini;
    for (int i = 0; i < n; ++i)
    {
        if (a[i] < minu)
        {
            minu = a[i];
            mini = i;
        }
    }

    int q = 0;
    for (int i = mini; i < n; ++i)
    {
        if (a[i] <= n)
        {
            if (a[i] != minu + q)
                return 0;
        }
        ++q;
    }
    for (int i = 0; i < mini; ++i)
    {
        if (a[i] <= n)
        {
            if (a[i] != minu + q)
                return 0;
        }
        ++q;
    }

    return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
    return 0;
}

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

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

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:30:9: warning: 'mini' may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |     int mini;
      |         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 17 ms 2432 KB Output is correct
7 Correct 33 ms 3960 KB Output is correct
8 Correct 28 ms 4344 KB Output is correct
9 Correct 7 ms 1536 KB Output is correct
10 Correct 28 ms 4864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 12 ms 2432 KB Output is correct
7 Correct 31 ms 4088 KB Output is correct
8 Correct 24 ms 4224 KB Output is correct
9 Correct 7 ms 1536 KB Output is correct
10 Correct 28 ms 4864 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 288 KB Output is correct
13 Correct 16 ms 2432 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 47 ms 5496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -