답안 #780135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780135 2023-07-12T06:52:44 Z NothingXD 곤돌라 (IOI14_gondola) C++17
40 / 100
18 ms 2124 KB
#include "gondola.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;

void debug_out(){cerr << endl;}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cout << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)



int valid(int n, int a[]){
	int idx = -1;
	vector<int> num;
	for (int i = 0; i < n; i++){
		if (a[i] <= n) idx = i;
		num.push_back(a[i]);
	}
	sort(all(num));
	num.resize(distance(num.begin(), unique(all(num))));
	if (num.size() < n) return 0;
	if (idx == -1) return 1;
	vector<int> v;
	idx -= (a[idx] - 1);
	for (int i = 0; i < n; i++){
		v.push_back(a[(idx+i)%n]);
	}
	for (int i = 0; i < n; i++){
		if (v[i] <= n && v[i] != i+1) return 0;
	}
	return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
   return -2;	
}

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

const int mod = 1e9 + 9;

int pwr(int a, int b){
	int res = 1;
	for (; b; b >>= 1, a = 1ll * a * a % mod) if (b & 1) res = 1ll * res * a % mod;
	return res;
}

const int maxn = 3e5 + 10;
bool mark[maxn];

int countReplacement(int n, int a[]){
	if (valid(n, a) == 0) return 0;
	int mx = *max_element(a, a + n);
	if (mx >= maxn) return -3;
	for (int i = 0; i < n; i++){
		mark[a[i]] = true;
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++){
		if (!mark[i]) cnt++;
	}
	int ans = 1;
	if (cnt == n) ans = n;
	for (int i = n+1; i <= mx; i++){
		if (mark[i]){
			cnt--;
		}
		else{
			ans = 1ll * ans * cnt % mod;
		}
	}
	/*
	vector<int> v;
	for (int i = 0; i < n; i++){
		if (a[i] > n) v.push_back(a[i]);
	}
	sort(all(v));
	int ans = 1;
	int lst = n, cnt = v.size();
	for (auto x: v){
		ans = 1ll * ans * pwr(cnt, x - lst - 1) % mod;
		lst = x;
		cnt--;
	}
	if (v.size() == n){
		ans = 1ll * ans * n % mod;
	}*/

	return ans;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:37:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |  if (num.size() < n) return 0;
      |      ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 236 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1108 KB Output is correct
7 Correct 12 ms 1460 KB Output is correct
8 Correct 8 ms 1804 KB Output is correct
9 Correct 4 ms 836 KB Output is correct
10 Correct 16 ms 2072 KB Output is correct
# 결과 실행 시간 메모리 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 300 KB Output is correct
6 Correct 6 ms 1208 KB Output is correct
7 Correct 12 ms 1480 KB Output is correct
8 Correct 9 ms 1912 KB Output is correct
9 Correct 4 ms 832 KB Output is correct
10 Correct 13 ms 1864 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 6 ms 1104 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 18 ms 1996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 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
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 12 ms 2124 KB Output is correct
10 Correct 10 ms 1492 KB Output is correct
11 Incorrect 4 ms 792 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 12 ms 2064 KB Output is correct
10 Correct 10 ms 1472 KB Output is correct
11 Incorrect 4 ms 852 KB Output isn't correct
12 Halted 0 ms 0 KB -