답안 #167637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167637 2019-12-09T07:33:31 Z Eae02 곤돌라 (IOI14_gondola) C++17
55 / 100
31 ms 4228 KB
#include "gondola.h"
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;

int valid(int n, int inputSeq[]) {
	for (int i = 0; i < n; i++)
		inputSeq[i]--;
	
	unordered_set<int> seen;
	
	int startIdx = -1;
	for (int i = 0; i < n; i++) {
		if (inputSeq[i] < n && startIdx == -1) {
			startIdx = i;
		}
		if (seen.count(inputSeq[i]))
			return 0;
		seen.insert(inputSeq[i]);
	}
	if (startIdx == -1) {
		return 1;
	}
	
	seen.clear();
	
	int g = inputSeq[startIdx];
	for (int i = 0; i < n; i++) {
		int idx = (i + startIdx) % n;
		if (inputSeq[idx] < n && inputSeq[idx] != g) {
			return 0;
		}
		g = (g + 1) % n;
	}
	
	return 1;
}

int replacement(int n, int inputSeq[], int replacementSeq[])
{
	for (int i = 0; i < n; i++)
		inputSeq[i]--;
	
	int startIdx = -1;
	for (int i = 0; i < n; i++) {
		if (inputSeq[i] < n) {
			startIdx = i;
			break;
		}
	}
	
	vector<pair<int, int>> br;
	
	int g;
	if (startIdx == -1) {
		g = 0;
		startIdx = 0;
	} else {
		g = inputSeq[startIdx];
	}
	
	for (int i = 0; i < n; i++) {
		int idx = (i + startIdx) % n;
		if (inputSeq[idx] >= n) {
			//cerr << inputSeq[idx] << ", should be " << g << "\n";
			br.emplace_back(inputSeq[idx] - n, g);
		}
		g = (g + 1) % n;
	}
	
	sort(all(br));
	
	int l = 0;
	for (auto b : br) {
		replacementSeq[l++] = b.second + 1;
		while (l <= b.first) {
			replacementSeq[l] = n + l;
			l++;
		}
	}
	
	return l;
}

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

int countReplacement(int n, int inputSeq[])
{
	return -3;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 12 ms 2088 KB Output is correct
7 Correct 13 ms 760 KB Output is correct
8 Correct 22 ms 3720 KB Output is correct
9 Correct 8 ms 1272 KB Output is correct
10 Correct 24 ms 4072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 12 ms 2088 KB Output is correct
7 Correct 13 ms 632 KB Output is correct
8 Correct 22 ms 3720 KB Output is correct
9 Correct 8 ms 1276 KB Output is correct
10 Correct 25 ms 4100 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 15 ms 1960 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 31 ms 4228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 12 ms 1144 KB Output is correct
12 Correct 14 ms 1272 KB Output is correct
13 Correct 17 ms 1528 KB Output is correct
14 Correct 12 ms 1144 KB Output is correct
15 Correct 23 ms 2404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -