Submission #1015273

# Submission time Handle Problem Language Result Execution time Memory
1015273 2024-07-06T08:14:43 Z parsadox2 Gondola (IOI14_gondola) C++17
55 / 100
24 ms 5664 KB
#include "gondola.h"

#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;

int valid(int n, int inputSeq[])
{
	int mn_pos = 0;
	for(int i = 1 ; i < n ; i++)  if(inputSeq[i] < inputSeq[mn_pos])
		mn_pos = i;
	vector <int> vec;
	for(int i = mn_pos ; i < n ; i++)
		vec.push_back(inputSeq[i]);
	for(int i = 0 ; i < mn_pos ; i++)
		vec.push_back(inputSeq[i]);
	set <int> st;
	for(auto u : vec)
		st.insert(u);
	if(st.size() != n)
		return 0;
	bool flg = true;
	for(int i = 1 ; i < n ; i++)  if(vec[i] <= n && vec[i] - vec[0] != i)
		flg = false;
	return flg;
}

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
	int mn_pos = 0;
	for(int i = 1 ; i < n ; i++)  if(gondolaSeq[i] < gondolaSeq[mn_pos])
		mn_pos = i;
	vector <int> vec;
	for(int i = mn_pos ; i < n ; i++)
		vec.push_back(gondolaSeq[i]);
	for(int i = 0 ; i < mn_pos ; i++)
		vec.push_back(gondolaSeq[i]);
	int mx = 0;
	for(int i = 0 ; i < n ; i++)
		mx = max(mx , vec[i]);
	int l = mx - n , pos = 0 , las = n;
	vector <pair<int , int>> bad;
	for(int i = 0 ; i < n ; i++)  if(vec[i] > n)
		bad.push_back(make_pair(vec[i] , i));
	if(vec[0] > n)
		vec[0] = 1;
	for(int i = 1 ; i < n ; i++)
	{
		vec[i] = vec[i - 1] + 1;
		if(vec[i - 1] == n)
			vec[i] = 1;
	}
	sort(bad.begin() , bad.end());
	for(auto u : bad)
	{
		while(las < u.F)
		{
			las++;
			replacementSeq[pos] = vec[u.S];
			vec[u.S] = las;
			pos++;
		}
	}
	return l;
}

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

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:21:15: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |  if(st.size() != n)
      |     ~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 2520 KB Output is correct
7 Correct 21 ms 4564 KB Output is correct
8 Correct 15 ms 4564 KB Output is correct
9 Correct 5 ms 1608 KB Output is correct
10 Correct 19 ms 5332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 2484 KB Output is correct
7 Correct 19 ms 4560 KB Output is correct
8 Correct 15 ms 4560 KB Output is correct
9 Correct 5 ms 1736 KB Output is correct
10 Correct 17 ms 5292 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 9 ms 2612 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 24 ms 5664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 440 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 6 ms 1752 KB Output is correct
12 Correct 6 ms 1780 KB Output is correct
13 Correct 9 ms 1508 KB Output is correct
14 Correct 6 ms 1748 KB Output is correct
15 Correct 12 ms 2320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -