Submission #73316

# Submission time Handle Problem Language Result Execution time Memory
73316 2018-08-28T07:12:35 Z TuGSGeReL Gondola (IOI14_gondola) C++14
Compilation error
0 ms 0 KB
#include "gondola.h"
#include<bits/stdc++.h>
#define ll int
#define mp make_pair
#define pub push_back
#define pob pop_back
#define ss second
#define ff first
#define ext exit(0)
using namespace std;
ll i,j,z=0,st,ans;
vector<ll> vc,vv;
vector<pair<ll,ll> >v;
map<ll,ll>m;
int gondolaSequence[100001];
int replacementSequence[250001];
int valid(int n, int inputSeq[])
{
	for(i=0;i<n;i++){
		if(m[inputSeq[i]]==1) return 0;
		m[inputSeq[i]]++;
	}
	for(i=0;i<n;i++){
		if(inputSeq[i]<n){
			st=(i-inputSeq[i]+1+n)%n;
			for(i=st;i<n;i++) vv.pub(inputSeq[i]);
			for(i=0;i<st;i++) vv.pub(inputSeq[i]);
			for(i=0;i<n;i++){
				if(vv[i]>n) continue;
				if(vv[i]!=i+1) return 0;
			}
			return 1;
		}
	}
	return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
	for(i=0;i<n;i++) gondolaSeq[i]--;
	
	for(i=0;i<n;i++){
		if(gondolaSeq[i] < n){
			st=(i-gondolaSeq[i]+n)%n;
		}
	}
	for(i=0;i<n;i++){
		if(gondolaSeq[i] >= n) v.pub(mp(gondolaSeq[i],(i-st+n)%n));
	}
	sort(v.begin(),v.end());
	if(v.size()==0) {
		return 0;
	}
	while(1){
		if(v.size()==1){
			while(v[0].ff>v[0].ss && v[0].ff>=n){
				if(v[0].ff-1>=n)vc.pub(v[0].ff-1);
				else vc.pub(v[0].ss);
				v[0].ff--;
			}
			break;
		}
		if(v.back().ff==v[v.size()-2].ff+1){
			vc.pub(v.back().ss);
			v.pob();
		}
		else {
			vc.pub(v.back().ff-1);
			v.back().ff--;
			if(v.back().ff==v.back().ss) v.pob();
		}
	}
	reverse(vc.begin(),vc.end());
	for(i=0;i<vc.size();i++) replacementSeq[i]=vc[i]+1;
	return vc.size();
}
int countReplacement(int n, int inputSeq[])
{
  return -3;
}

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:72:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<vc.size();i++) replacementSeq[i]=vc[i]+1;
          ~^~~~~~~~~~
/tmp/cc0I14Fy.o:(.bss+0xf4260): multiple definition of `gondolaSequence'
/tmp/ccKQulen.o:(.bss+0xf4260): first defined here
/tmp/cc0I14Fy.o:(.bss+0x0): multiple definition of `replacementSequence'
/tmp/ccKQulen.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status