답안 #1102896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102896 2024-10-19T08:20:02 Z alexander707070 곤돌라 (IOI14_gondola) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "gondola.h"

#define MAXN 500007
using namespace std;

int n,pos;
int s[MAXN],last,maxs,where[MAXN];
bool li[MAXN];

int valid(int N, int inputSeq[]){
	n=N;

	int mins=1;
	for(int i=1;i<=n;i++){
		s[i]=inputSeq[i-1];
		s[i+n]=s[i];

		if(s[i]<s[mins]){
			mins=i;
		}
	}

	for(int i=mins;i<mins+n;i++){
		if(s[i]<=n and s[i]!=s[mins]+i-mins)return 0;

		if(s[i]>n){
			if(li[s[i]])return 0;
			li[s[i]]=true;
		}
	}

	return 1;
}

int replacement(int N, int gondolaSeq[], int replacementSeq[]){
	n=N;

	maxs=1;
	for(int i=1;i<=n;i++){
		s[i]=gondolaSeq[i-1];
		
		if(s[i]>s[maxs])maxs=i;
		if(s[i]<=n)pos=i;

		where[s[i]]=i;
	}

	if(pos==0){
		for(int i=1;i<=n;i++)val[i]=i;
	}else{
		for(int i=pos;i<=n;i++)val[i]=s[pos]+i-pos;
		for(int i=1;i<pos;i++)val[i]=val[n]+i;

		for(int i=1;i<=n;i++){
			if(val[i]>n)val[i]-=n;
		}
	}

	for(int i=n+1;i<=s[maxs];i++){
		if(where[i]==0){
			replacementSeq[i-n-1]=val[maxs];
			val[maxs]=i;
		}else{
			replacementSeq[i-n-1]=val[where[i]];
			val[where[i]]=i;
		}
	}

	return s[maxs]-n;
}

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

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

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:50:24: error: 'val' was not declared in this scope; did you mean 'valid'?
   50 |   for(int i=1;i<=n;i++)val[i]=i;
      |                        ^~~
      |                        valid
gondola.cpp:52:26: error: 'val' was not declared in this scope; did you mean 'valid'?
   52 |   for(int i=pos;i<=n;i++)val[i]=s[pos]+i-pos;
      |                          ^~~
      |                          valid
gondola.cpp:53:25: error: 'val' was not declared in this scope; did you mean 'valid'?
   53 |   for(int i=1;i<pos;i++)val[i]=val[n]+i;
      |                         ^~~
      |                         valid
gondola.cpp:56:7: error: 'val' was not declared in this scope; did you mean 'valid'?
   56 |    if(val[i]>n)val[i]-=n;
      |       ^~~
      |       valid
gondola.cpp:62:26: error: 'val' was not declared in this scope; did you mean 'valid'?
   62 |    replacementSeq[i-n-1]=val[maxs];
      |                          ^~~
      |                          valid
gondola.cpp:65:26: error: 'val' was not declared in this scope; did you mean 'valid'?
   65 |    replacementSeq[i-n-1]=val[where[i]];
      |                          ^~~
      |                          valid