Submission #737723

# Submission time Handle Problem Language Result Execution time Memory
737723 2023-05-07T15:27:25 Z shoryu386 Gondola (IOI14_gondola) C++17
55 / 100
33 ms 6076 KB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[])
{
	int baseline = -1;
	int baselineIdx = -1;
	for (int x = 0; x < n; x++){
		if (inputSeq[x] <= n){
			baseline = inputSeq[x];
			baselineIdx = x;
		}
	}
	unordered_set<int> hmm;
	for (int x = 0; x < n; x++){
		if (hmm.count(inputSeq[x]) != 0) return 0;
		hmm.insert(inputSeq[x]);
	}
	
	if (baseline == -1){
		return 1;
	}
	
	//baseline is supposed to be at x+1
	int shiftsRight = baselineIdx+1 - baseline;
	int shifted[n];
	for (int x = 0; x < n; x++) {
		shifted[x] = inputSeq[(x + shiftsRight + n)%n];
	}
	hmm.clear();
	
	for (int x = 0; x < n; x++){
		if (shifted[x] <= n && shifted[x] != x+1) return 0;
		
		if (hmm.count(shifted[x]) != 0) return 0;
		hmm.insert(shifted[x]);
	}
	return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
	
	int baseline = -1;
	int baselineIdx = -1;
	for (int x = 0; x < n; x++){
		if (gondolaSeq[x] <= n){
			baseline = gondolaSeq[x];
			baselineIdx = x;
		}
	}
	int shifted[n];
	if (baseline != -1){
		//baseline is supposed to be at x+1
		int shiftsRight = baselineIdx+1 - baseline;
		for (int x = 0; x < n; x++) {
			shifted[x] = gondolaSeq[(x + shiftsRight + n)%n];
		}
	}
	else for (int x = 0; x < n; x++) shifted[x] = gondolaSeq[x];
	
	map<int, int> hhh;
	for (int x = 0; x < n; x++){
		hhh[shifted[x]] = x;
	}
	
	int hmm[n];
	for (int x = 0; x < n; x++) hmm[x] = x+1;
	int nextRep = n+1;
	vector<int> ans;
	for (auto i : hhh){
		int val = i.first, idx = i.second;
		
		while (hmm[idx] < val){
			ans.push_back(hmm[idx]);
			hmm[idx] = nextRep;
			nextRep++;
		}
	}
	
	int cnt = 0;
	for (int x : ans) replacementSeq[cnt] = x, cnt++;
	return (int)ans.size();
	
}

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

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 12 ms 2236 KB Output is correct
7 Correct 8 ms 1084 KB Output is correct
8 Correct 15 ms 4096 KB Output is correct
9 Correct 5 ms 1600 KB Output is correct
10 Correct 17 ms 4708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 8 ms 2224 KB Output is correct
7 Correct 8 ms 1068 KB Output is correct
8 Correct 19 ms 4068 KB Output is correct
9 Correct 5 ms 1620 KB Output is correct
10 Correct 17 ms 4608 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 308 KB Output is correct
13 Correct 8 ms 2204 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 23 ms 5708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 33 ms 5332 KB Output is correct
12 Correct 29 ms 6076 KB Output is correct
13 Correct 22 ms 3276 KB Output is correct
14 Correct 24 ms 5320 KB Output is correct
15 Correct 23 ms 3276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -