답안 #232074

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
232074 2020-05-16T00:51:46 Z anonymous 곤돌라 (IOI14_gondola) C++14
55 / 100
25 ms 3328 KB
#include "gondola.h"
#include <vector>
#include <iostream>
#define MAXN 100005
#define MAXV 250005
using namespace std;

int valid(int n, int Seq[])
{
  bool has[MAXV]={}, b = false;
  int pos, v;
  for (int i=0; i<n; i++) {
      if (Seq[i] <= n) {
            pos = i;
            v = Seq[i];
      }
      if (has[Seq[i]]) {return(0);}
      has[Seq[i]]=true;

  }
  for (int i=0; i<n; i++) {
    if (Seq[pos] > n) {}
    else if (Seq[pos] != v) {return(0);}
    pos = (pos+1) %n;
    v= v == n ? 1 : v+1;
  }
  return(1);
}

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

int replacement(int n, int Seq[], int ans[])
{
  int mx = 0, first=0, pos[MAXV]={}, Cur[MAXN];
  bool b = false;
  for (int i=0; i<n; i++) {
    if (Seq[i] > n) {
        pos[Seq[i]] = i+1;
        if (!first) {first = i+1;}
    } else if (!b) {
        int p = i+1, v = Seq[i];
        for (int j=0; j<n; j++) {
            Cur[p] = v;
            p = p == n ? 1: p+1;
            v = v == n ? 1: v+1;
        }
        b=true;
    }
    mx = max(mx, Seq[i]);
  }
  if (!b) {
    for (int i=1; i<=n; i++) {Cur[i] = i;}
  }
  for (int i=n+1; i<=mx; i++) {
    if (pos[i] == 0) {
        ans[i - n - 1] = Cur[first];
        Cur[first] = i;
    } else {
        ans[i - n - 1] = Cur[pos[i]];
        Cur[pos[i]] = i;
        while (Cur[first] == Seq[first-1]) {first++;}
    }
  }
  return(mx - n);
}

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

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

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:10:22: warning: unused variable 'b' [-Wunused-variable]
   bool has[MAXV]={}, b = false;
                      ^
gondola.cpp:25:15: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
     v= v == n ? 1 : v+1;
        ~~~~~~~^~~~~~~~~
gondola.cpp:22:16: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (Seq[pos] > n) {}
                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 10 ms 768 KB Output is correct
7 Correct 18 ms 1024 KB Output is correct
8 Correct 15 ms 896 KB Output is correct
9 Correct 8 ms 640 KB Output is correct
10 Correct 17 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 640 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 10 ms 640 KB Output is correct
7 Correct 17 ms 896 KB Output is correct
8 Correct 15 ms 896 KB Output is correct
9 Correct 8 ms 640 KB Output is correct
10 Correct 17 ms 896 KB Output is correct
11 Correct 5 ms 640 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 10 ms 640 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 18 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1280 KB Output is correct
2 Correct 5 ms 1280 KB Output is correct
3 Correct 5 ms 1280 KB Output is correct
4 Correct 5 ms 1280 KB Output is correct
5 Correct 5 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1280 KB Output is correct
2 Correct 5 ms 1280 KB Output is correct
3 Correct 5 ms 1280 KB Output is correct
4 Correct 5 ms 1280 KB Output is correct
5 Correct 6 ms 1408 KB Output is correct
6 Correct 5 ms 1280 KB Output is correct
7 Correct 5 ms 1280 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 6 ms 1408 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1280 KB Output is correct
2 Correct 5 ms 1280 KB Output is correct
3 Correct 5 ms 1280 KB Output is correct
4 Correct 5 ms 1280 KB Output is correct
5 Correct 5 ms 1280 KB Output is correct
6 Correct 5 ms 1280 KB Output is correct
7 Correct 5 ms 1280 KB Output is correct
8 Correct 6 ms 1408 KB Output is correct
9 Correct 6 ms 1408 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 16 ms 2432 KB Output is correct
12 Correct 18 ms 2560 KB Output is correct
13 Correct 18 ms 2560 KB Output is correct
14 Correct 16 ms 2304 KB Output is correct
15 Correct 25 ms 3328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 384 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 256 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -