답안 #819556

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
819556 2023-08-10T11:44:26 Z Yey 곤돌라 (IOI14_gondola) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "gondola.h"
#define ll long long
#define mod 1000000007
using namespace std;

int replacement(int n, int gondolaSeq[], int replacementSeq[]);
int countReplacement(int n, int inputSeq[]);

int valid(int n,int inputSeq[]){
	int mn = INT_MAX;
	int id;
	for(int i = 0 ; i < n ; i++){
		if( mn > inputSeq[i] ){
			mn = inputSeq[i];
			id = i;
		}
	}
	if( mn > n ) return 1;
	vector<int> v;
	mn--;
	id = (id-mn)%n+n;
	id %= n;
	for(int i =  id ; i < n ; i++) v.push_back(inputSeq[i]);
	for(int i = 0 ; i < id ; i++) v.push_back(inputSeq[i]);
	for(int i = 0 ; i < n ; i++){
		if( v[i] <= n && v[i] != i+1 ) return 0;
	}
	return 1;
}

//~ int main(){
  //~ ios_base::sync_with_stdio(false);
  //~ cin.tie(0);
  //~ cout.tie(0);
  //~ cin>>n;
  //~ for(int i = 0 ; i < n ; i++){
		//~ cin>>inputSeq[i];
	//~ }
	//~ cout<<valid(n)<<"\n";
  //~ ll T = 1;
  //~ //cin>>T;
  //~ for(int i = 0 ; i < T ; i++){
    //~ solve();
  //~ }
//~ }

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:22:10: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |  id = (id-mn)%n+n;
      |       ~~~^~~~
/usr/bin/ld: /tmp/cc6t3Boz.o: in function `main':
grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
/usr/bin/ld: grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status