Submission #805683

# Submission time Handle Problem Language Result Execution time Memory
805683 2023-08-03T20:21:29 Z IvanJ Gondola (IOI14_gondola) C++17
55 / 100
25 ms 4556 KB
#include "gondola.h"
#include<bits/stdc++.h>

#define pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

int valid(int n, int A[]) {
	int pos = -1;
	for(int i = 0;i < n;i++) A[i]--;
	set<int> s;
	for(int i = 0;i < n;i++) s.insert(A[i]);
	if(s.size() != n) return 0;
	for(int i = 0;i < n;i++) 
		if(A[i] < n) pos = i;
	if(pos == -1) return 1;
	for(int i = pos;i < pos + n;i++)
		if(A[i % n] < n && A[i % n] != (A[pos] + (i - pos)) % n)
			return 0;
	return 1;
}

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

int replacement(int n, int A[], int R[]) {
	int maxi = 0;
	for(int i = 0;i < n;i++) 
		maxi = max(maxi, --A[i]);
	
	vector<int> v(maxi + 1, -1);
	for(int i = 0;i < n;i++) 
		v[A[i]] = i;
	
	vector<int> poc;
	for(int i = 0;i < n;i++) poc.pb(i);
	int pos = -1;
	for(int i = 0;i < n;i++) 
		if(A[i] < n) pos = i;
	if(pos != -1) 
		for(int i = pos;i < pos + n;i++) 
			poc[i % n] = (A[pos] + (i - pos)) % n;
	
	pos = -1;
	for(int i = 0;i < n;i++) 
		if(A[i] == maxi) pos = i;
	
	int idx = 0;
	for(int i = n;i <= maxi;i++) {
		if(v[i] != -1) 
			R[idx++] = poc[v[i]] + 1;
		else R[idx++] = poc[pos] + 1, poc[pos] = i;
	}
	return idx;
}

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

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

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:19:14: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |  if(s.size() != n) return 0;
      |     ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 9 ms 2200 KB Output is correct
7 Correct 21 ms 3668 KB Output is correct
8 Correct 15 ms 3852 KB Output is correct
9 Correct 5 ms 1364 KB Output is correct
10 Correct 20 ms 4492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 9 ms 2132 KB Output is correct
7 Correct 20 ms 3668 KB Output is correct
8 Correct 15 ms 3820 KB Output is correct
9 Correct 6 ms 1364 KB Output is correct
10 Correct 20 ms 4544 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 10 ms 2004 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 25 ms 4556 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 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 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 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 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 308 KB Output is correct
11 Correct 8 ms 1916 KB Output is correct
12 Correct 9 ms 2100 KB Output is correct
13 Correct 10 ms 1616 KB Output is correct
14 Correct 8 ms 2000 KB Output is correct
15 Correct 15 ms 2336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -