답안 #401234

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
401234 2021-05-09T16:41:18 Z victoriad 곤돌라 (IOI14_gondola) C++14
10 / 100
14 ms 1120 KB
#include "gondola.h"
#include <cmath>
#include <cstdio>
#include <vector>
using namespace std;


int valid(int n, int inputSeq[])
{ int x,y,i,z;
vector<bool>t(n,false);
  for(i=0;i<n;i++){
  if(inputSeq[i]<=n){
    x=inputSeq[i]-i;
    y=inputSeq[i];
	z=i;
	t[inputSeq[i]]=true;
    break;
  }
  }
  bool p=true;
  i++;
  for(;i<n-y+z+1;i++){
    if(inputSeq[i]<=n){
	 if(inputSeq[i]-x!=i||t[inputSeq[i]]){
      p=false;
      break;
	 }
	if(!t[inputSeq[i]]){
		t[inputSeq[i]]=true;
	}
    }
  }
  if(p){
	  int o=0;
    for( i=n-x+1;i<n;i++){
		o++;
      if(inputSeq[i]<=n && inputSeq[i]!=o){
        p=false;
        break;
      }
    }
  }
  if(p)return 1;
  else return 0;
}


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

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

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

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

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:22:13: warning: 'z' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |   for(;i<n-y+z+1;i++){
      |          ~~~^~
gondola.cpp:22:11: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |   for(;i<n-y+z+1;i++){
      |          ~^~
gondola.cpp:35:13: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |     for( i=n-x+1;i<n;i++){
      |            ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 6 ms 588 KB Output is correct
7 Correct 14 ms 1076 KB Output is correct
8 Correct 10 ms 972 KB Output is correct
9 Correct 4 ms 428 KB Output is correct
10 Correct 12 ms 1064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 6 ms 588 KB Output is correct
7 Correct 12 ms 1120 KB Output is correct
8 Correct 13 ms 936 KB Output is correct
9 Correct 4 ms 460 KB Output is correct
10 Correct 12 ms 1100 KB Output is correct
11 Incorrect 1 ms 204 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 296 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 288 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -