답안 #51921

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51921 2018-06-22T16:24:23 Z zetapi 곤돌라 (IOI14_gondola) C++14
컴파일 오류
0 ms 0 KB
#include <gondola.h>
#include <bits/stdc++.h>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=5e5;

int arr[MAX],fre[MAX];

int valid(int n=5,vector<int> inputSeq={10, 4, 3, 11, 12})
{
  int N=n,ok=1;
  for(int A=0;A<N;A++)
  {
	  fre[inputSeq[A]]++;
	  if(fre[inputSeq[A]]>1)
	  	return 0;
  }
  for(int A=0;A<N;A++)
  {
  	  if(inputSeq[A]<=N)
  	  {
		 ok=0;
		 inputSeq[A]--;
		 for(int B=A;B>=0;B--)
		 {
		 	arr[B]=inputSeq[A];
		 	inputSeq[A]--;
		 	if(inputSeq[A]<0)
		 		inputSeq[A]+=N;
		 }
		 inputSeq[A]=arr[A];
		 for(int B=A+1;B<N;B++)
		 {
		 	inputSeq[A]++;
		 	if(inputSeq[A]>=N)
		 		inputSeq[A]=0;
		 	arr[B]=inputSeq[A];
		 }
		 inputSeq[A]=arr[A]+1;
		 break;
	  }
  }
  if(ok)
  	 return 1;
  for(int A=0;A<N;A++)
  	 arr[A]++;
 // for(int A=0;A<N;A++)
  ///	 cout<<arr[A]<<" ";
  for(int A=0;A<N;A++)
  {
  	 // cout<<arr[A]<<" "<<inputSeq[A]<<"\n";
  	  if(inputSeq[A]<=N and arr[A]!=inputSeq[A])
  	  	return 0;	
  }
  	return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  return -2;
}

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

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

/*int main()
{
	ios_base::sync_with_stdio(false);

	cout<<"hp ";	
	cout<<valid()<<"\n";
	return 0;
}*/#include <gondola.h>
#include <bits/stdc++.h>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=5e5;

int arr[MAX],fre[MAX];

int valid(int n=5,int inputSeq[])
{
  int N=n,ok=1;
  for(int A=0;A<N;A++)
  {
	  fre[inputSeq[A]]++;
	  if(fre[inputSeq[A]]>1)
	  	return 0;
  }
  for(int A=0;A<N;A++)
  {
  	  if(inputSeq[A]<=N)
  	  {
		 ok=0;
		 inputSeq[A]--;
		 for(int B=A;B>=0;B--)
		 {
		 	arr[B]=inputSeq[A];
		 	inputSeq[A]--;
		 	if(inputSeq[A]<0)
		 		inputSeq[A]+=N;
		 }
		 inputSeq[A]=arr[A];
		 for(int B=A+1;B<N;B++)
		 {
		 	inputSeq[A]++;
		 	if(inputSeq[A]>=N)
		 		inputSeq[A]=0;
		 	arr[B]=inputSeq[A];
		 }
		 inputSeq[A]=arr[A]+1;
		 break;
	  }
  }
  if(ok)
  	 return 1;
  for(int A=0;A<N;A++)
  	 arr[A]++;
 // for(int A=0;A<N;A++)
  ///	 cout<<arr[A]<<" ";
  for(int A=0;A<N;A++)
  {
  	 // cout<<arr[A]<<" "<<inputSeq[A]<<"\n";
  	  if(inputSeq[A]<=N and arr[A]!=inputSeq[A])
  	  	return 0;	
  }
  	return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  return -2;
}

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

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

/*int main()
{
	ios_base::sync_with_stdio(false);

	cout<<"hp ";	
	cout<<valid()<<"\n";
	return 0;
}*/

Compilation message

gondola.cpp:94:11: error: redefinition of 'const int MAX'
 const int MAX=5e5;
           ^~~
gondola.cpp:12:11: note: 'const int MAX' previously defined here
 const int MAX=5e5;
           ^~~
gondola.cpp:96:12: error: redefinition of 'int arr [500000]'
 int arr[MAX],fre[MAX];
            ^
gondola.cpp:14:5: note: 'int arr [500000]' previously declared here
 int arr[MAX],fre[MAX];
     ^~~
gondola.cpp:96:21: error: redefinition of 'int fre [500000]'
 int arr[MAX],fre[MAX];
                     ^
gondola.cpp:14:14: note: 'int fre [500000]' previously declared here
 int arr[MAX],fre[MAX];
              ^~~
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:98:5: error: default argument missing for parameter 2 of 'int valid(int, int*)'
 int valid(int n=5,int inputSeq[])
     ^~~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:146:5: error: redefinition of 'int replacement(int, int*, int*)'
 int replacement(int n, int gondolaSeq[], int replacementSeq[])
     ^~~~~~~~~~~
gondola.cpp:64:5: note: 'int replacement(int, int*, int*)' previously defined here
 int replacement(int n, int gondolaSeq[], int replacementSeq[])
     ^~~~~~~~~~~
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:153:5: error: redefinition of 'int countReplacement(int, int*)'
 int countReplacement(int n, int inputSeq[])
     ^~~~~~~~~~~~~~~~
gondola.cpp:71:5: note: 'int countReplacement(int, int*)' previously defined here
 int countReplacement(int n, int inputSeq[])
     ^~~~~~~~~~~~~~~~