답안 #1001342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1001342 2024-06-18T21:52:35 Z ZeroCool 곤돌라 (IOI14_gondola) C++14
20 / 100
23 ms 5468 KB
#include "gondola.h"
#include <bits/stdc++.h>

using namespace std;

int valid(int n, int A[]){
	int B[n];
	int p;
	
	set<int> s;
	for(int i = 0;i < n;i++)s.insert(A[i]);
	if(s.size() < n)return 0;
	
	for(int i = 0;i< n;i++){
		if(A[i] <= n){
			p = i;
			B[i] = A[i];
			break;
		}
	}
	
	for(int i = p + 1;i < n;i++){
		B[i] = B[i-1] + 1;
	}
	for(int i = p - 1;i >= 0;i--){
		B[i] = B[i + 1] - 1;
	}
	
	for(int i = 0;i < n;i ++){
		if(B[i] > n) B[i] -= n;
		if(B[i] <= 0) B[i] += n;
	}
	
	for(int i = 0;i<n;i++){
		if(A[i] > n)continue;
		if(A[i] != B[i])return 0;
	}
	
	return 1;
}

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

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:12:14: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |  if(s.size() < n)return 0;
      |     ~~~~~~~~~^~~
gondola.cpp:22:10: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |  for(int i = p + 1;i < n;i++){
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 444 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 380 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 7 ms 2652 KB Output is correct
7 Correct 19 ms 4444 KB Output is correct
8 Correct 12 ms 4640 KB Output is correct
9 Correct 5 ms 1628 KB Output is correct
10 Correct 17 ms 5432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 2636 KB Output is correct
7 Correct 19 ms 4600 KB Output is correct
8 Correct 12 ms 4700 KB Output is correct
9 Correct 5 ms 1628 KB Output is correct
10 Correct 17 ms 5468 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 444 KB Output is correct
13 Correct 8 ms 2364 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 23 ms 5468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -