답안 #805674

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
805674 2023-08-03T20:11:08 Z IvanJ 곤돌라 (IOI14_gondola) C++17
25 / 100
24 ms 4688 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;
	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;
      |     ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 8 ms 2148 KB Output is correct
7 Correct 22 ms 3564 KB Output is correct
8 Correct 20 ms 3892 KB Output is correct
9 Correct 6 ms 1416 KB Output is correct
10 Correct 20 ms 4412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 8 ms 2168 KB Output is correct
7 Correct 20 ms 3596 KB Output is correct
8 Correct 16 ms 3852 KB Output is correct
9 Correct 5 ms 1464 KB Output is correct
10 Correct 19 ms 4440 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 11 ms 2004 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 24 ms 4688 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 304 KB Output is correct
5 Correct 1 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 Incorrect 1 ms 296 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 308 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -