답안 #65288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65288 2018-08-07T10:06:23 Z gnoor 곤돌라 (IOI14_gondola) C++17
55 / 100
28 ms 4440 KB
#include "gondola.h"

#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

bool mark[300100];

int valid(int n, int inputSeq[])
{
	int key=-1;
	int id=-1;
	int cur;
	for (int i=0;i<n;i++) {
		inputSeq[i]--;
		if (mark[inputSeq[i]]) return 0;
		mark[inputSeq[i]]=true;
	}
	for (int i=0;i<n;i++) {
		if (inputSeq[i]>=n) continue;
		key=inputSeq[i];
		id=i;
	}
	for (int i=0;i<n;i++) {
		if (inputSeq[i]>=n) continue;
		cur=key+i-id;
		cur%=n;
		cur+=n;
		cur%=n;
		if (inputSeq[i]!=cur) return 0;
	}
	return 1;
}

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

int init[100100];
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
	int id=0;
	int key=1;
	for (int i=0;i<n;i++) {
		if (gondolaSeq[i]>n) continue;
		id=i;
		key=gondolaSeq[i];
		break;
	}
	init[id]=key;
	for (int i=id+1;i<n;i++) {
		init[i]=init[i-1]+1;
		if (init[i]>n) init[i]-=n;
	}
	for (int i=id-1;i>=0;i--) {
		init[i]=init[i+1]-1;
		if (init[i]<=0) init[i]+=n;
	}

	vector<pair<int,int>> ei;
	for (int i=0;i<n;i++) {
		if (gondolaSeq[i]<=n) continue;
		ei.push_back({gondolaSeq[i],i});
	}
	sort(ei.begin(),ei.end());

	int sz=0;
	int curid=0;
	int curcar=n+1;
	int curgon=0;
	for (int i=0;i<(int)ei.size();i++) {
		while (curcar<ei[i].first) {
			while (init[curgon]==gondolaSeq[curgon]) curgon++;
			replacementSeq[sz++]=init[curgon];
			init[curgon]=curcar;
			curcar++;
		}
		replacementSeq[sz++]=init[ei[i].second];
		init[ei[i].second]=ei[i].first;
		curcar++;
	}
	return sz;
}

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

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

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:69:6: warning: unused variable 'curid' [-Wunused-variable]
  int curid=0;
      ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 3 ms 500 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 644 KB Output is correct
2 Correct 2 ms 644 KB Output is correct
3 Correct 3 ms 644 KB Output is correct
4 Correct 2 ms 644 KB Output is correct
5 Correct 3 ms 644 KB Output is correct
6 Correct 9 ms 772 KB Output is correct
7 Correct 16 ms 1060 KB Output is correct
8 Correct 13 ms 1060 KB Output is correct
9 Correct 6 ms 1060 KB Output is correct
10 Correct 16 ms 1060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1060 KB Output is correct
2 Correct 2 ms 1060 KB Output is correct
3 Correct 11 ms 1060 KB Output is correct
4 Correct 2 ms 1060 KB Output is correct
5 Correct 2 ms 1060 KB Output is correct
6 Correct 8 ms 1060 KB Output is correct
7 Correct 15 ms 1060 KB Output is correct
8 Correct 16 ms 1060 KB Output is correct
9 Correct 5 ms 1060 KB Output is correct
10 Correct 16 ms 1060 KB Output is correct
11 Correct 2 ms 1060 KB Output is correct
12 Correct 2 ms 1060 KB Output is correct
13 Correct 8 ms 1060 KB Output is correct
14 Correct 2 ms 1060 KB Output is correct
15 Correct 15 ms 1060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1060 KB Output is correct
2 Correct 2 ms 1060 KB Output is correct
3 Correct 3 ms 1060 KB Output is correct
4 Correct 2 ms 1060 KB Output is correct
5 Correct 2 ms 1060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1060 KB Output is correct
2 Correct 3 ms 1060 KB Output is correct
3 Correct 2 ms 1060 KB Output is correct
4 Correct 2 ms 1060 KB Output is correct
5 Correct 2 ms 1060 KB Output is correct
6 Correct 2 ms 1060 KB Output is correct
7 Correct 2 ms 1060 KB Output is correct
8 Correct 2 ms 1060 KB Output is correct
9 Correct 3 ms 1060 KB Output is correct
10 Correct 3 ms 1060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1060 KB Output is correct
2 Correct 2 ms 1060 KB Output is correct
3 Correct 3 ms 1060 KB Output is correct
4 Correct 4 ms 1060 KB Output is correct
5 Correct 2 ms 1060 KB Output is correct
6 Correct 2 ms 1060 KB Output is correct
7 Correct 3 ms 1060 KB Output is correct
8 Correct 4 ms 1060 KB Output is correct
9 Correct 3 ms 1060 KB Output is correct
10 Correct 3 ms 1060 KB Output is correct
11 Correct 16 ms 1796 KB Output is correct
12 Correct 15 ms 2380 KB Output is correct
13 Correct 22 ms 3024 KB Output is correct
14 Correct 14 ms 3092 KB Output is correct
15 Correct 28 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4440 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4440 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4440 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4440 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -