제출 #52099

#제출 시각아이디문제언어결과실행 시간메모리
52099spencercompton곤돌라 (IOI14_gondola)C++17
55 / 100
53 ms5108 KiB
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;

int valid(int n, int inputSeq[])
{
	set<int> ss;
	for(int i = 0; i<n; i++){
		ss.insert(inputSeq[i]);
	}
	if(ss.size()!=n){
		return 0;
	}
	pair<int, int> first;
	first.first = n+1;
	first.second = -1;
	for(int i = 0; i<n; i++){
		if(inputSeq[i]<first.first){
			first.first = inputSeq[i];
			first.second = i;
		}
	}
	if(first.second==-1){
		return 1;
	}
	int pos = first.second;
	for(int i = 0; i<n; i++){
		if(inputSeq[i]<=n && i!=((first.second+inputSeq[i]-first.first)%n)){
			return 0;
		}
	}
	return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
	pair<int, int> first;
	first.first = n+1;
	first.second = -1;
	for(int i = 0; i<n; i++){
		if(gondolaSeq[i]<first.first){
			first.first = gondolaSeq[i];
			first.second = i;
		}
	}
	if(first.second==-1){
		first.first = 1;
		first.second = 0;
	}
	int cur[n];
	for(int i = 1; i<=n; i++){
		int pos = (i-first.first+first.second+n+n)%n;
		cur[pos] = i;
	}
	vector<pair<int, int> > final;
	for(int i = 0; i<n; i++){
		final.push_back(make_pair(gondolaSeq[i],i));
	}
	sort(final.begin(),final.end());
	int point = n+1;
	int p = 0;
	for(int i = 0; i<n; i++){
		while(point<=final[i].first){
			replacementSeq[p++] = cur[final[i].second];
			cur[final[i].second] = point++;
		}
	}
	return p;
}

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

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

컴파일 시 표준 에러 (stderr) 메시지

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:11:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(ss.size()!=n){
     ~~~~~~~~~^~~
gondola.cpp:26:6: warning: unused variable 'pos' [-Wunused-variable]
  int pos = first.second;
      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...