Submission #55583

# Submission time Handle Problem Language Result Execution time Memory
55583 2018-07-08T07:10:35 Z leejseo Gondola (IOI14_gondola) C++
55 / 100
25 ms 2440 KB
#include "gondola.h"
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int, int> pii;

int valid(int n, int inputSeq[])
{
	int min_val = 1000000, min_index = -1;
	vector<int> L;
	for (int i=0; i<n; i++){
		L.push_back(inputSeq[i]);
		if (min_val > inputSeq[i]){
			min_index = i;
			min_val = inputSeq[i];
		}
	}
	sort(L.begin(), L.end());
	for (int i=1; i<n; i++) {
		if (L[i] == L[i-1]) return 0;
	}
	int mi = -1;
	for (int i=0; i<n; i++){
		if (L[i] > n && mi == -1) mi = i;
		if (mi > -1 && L[i] != n+i-mi+1) return 0;
	}
	L.clear();
	int bi = min_index;
	for (int j=1; j<n; j++){
		int i = (j + min_index) % n;
		if (inputSeq[i] > n) continue;
		if (inputSeq[i] < inputSeq[bi]) return 0;
		bi = i;
	}
	return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  int min_val = 1000000, min_index = -1;
	vector<pii> L;
	for (int i=0; i<n; i++){
		if (min_val > gondolaSeq[i]){
			min_index = i;
			min_val = gondolaSeq[i];
		} 
	}	
	bool b = (min_val > n);	
	for (int j=0; j<n; j++){
			int i = min_index + j;
			int c;
			if (b) c = j;
			else{
				c = (j + min_val)%n;
			}	
			L.push_back(pii(gondolaSeq[i%n], (c == 0 ? n : c)));
	}	
	sort(L.begin(), L.end());	
	int l = 0;
	for (int i=0; i<n; i++){		
		while (L[i].first != L[i].second){
			replacementSeq[l] = L[i].second;
			l++;
			L[i].second = n+l;
		}
	}	
	return l;
}

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

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
# Verdict Execution time Memory 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 3 ms 428 KB Output is correct
5 Correct 3 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 520 KB Output is correct
2 Correct 2 ms 576 KB Output is correct
3 Correct 2 ms 608 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
5 Correct 2 ms 608 KB Output is correct
6 Correct 13 ms 1124 KB Output is correct
7 Correct 21 ms 1504 KB Output is correct
8 Correct 20 ms 1512 KB Output is correct
9 Correct 9 ms 1512 KB Output is correct
10 Correct 22 ms 1512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1512 KB Output is correct
2 Correct 2 ms 1512 KB Output is correct
3 Correct 2 ms 1512 KB Output is correct
4 Correct 2 ms 1512 KB Output is correct
5 Correct 1 ms 1512 KB Output is correct
6 Correct 10 ms 1512 KB Output is correct
7 Correct 21 ms 1612 KB Output is correct
8 Correct 16 ms 1612 KB Output is correct
9 Correct 8 ms 1612 KB Output is correct
10 Correct 23 ms 1612 KB Output is correct
11 Correct 2 ms 1612 KB Output is correct
12 Correct 2 ms 1612 KB Output is correct
13 Correct 11 ms 1612 KB Output is correct
14 Correct 2 ms 1612 KB Output is correct
15 Correct 25 ms 1612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1612 KB Output is correct
2 Correct 2 ms 1612 KB Output is correct
3 Correct 2 ms 1612 KB Output is correct
4 Correct 2 ms 1612 KB Output is correct
5 Correct 2 ms 1612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1612 KB Output is correct
2 Correct 2 ms 1612 KB Output is correct
3 Correct 2 ms 1612 KB Output is correct
4 Correct 2 ms 1612 KB Output is correct
5 Correct 2 ms 1612 KB Output is correct
6 Correct 2 ms 1612 KB Output is correct
7 Correct 3 ms 1612 KB Output is correct
8 Correct 3 ms 1612 KB Output is correct
9 Correct 3 ms 1612 KB Output is correct
10 Correct 3 ms 1612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1612 KB Output is correct
2 Correct 2 ms 1612 KB Output is correct
3 Correct 2 ms 1612 KB Output is correct
4 Correct 2 ms 1612 KB Output is correct
5 Correct 2 ms 1612 KB Output is correct
6 Correct 2 ms 1612 KB Output is correct
7 Correct 2 ms 1612 KB Output is correct
8 Correct 2 ms 1612 KB Output is correct
9 Correct 3 ms 1612 KB Output is correct
10 Correct 3 ms 1612 KB Output is correct
11 Correct 17 ms 2052 KB Output is correct
12 Correct 18 ms 2052 KB Output is correct
13 Correct 19 ms 2052 KB Output is correct
14 Correct 22 ms 2068 KB Output is correct
15 Correct 24 ms 2440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2440 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2440 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2440 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2440 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -