답안 #780175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780175 2023-07-12T07:07:29 Z NothingXD 곤돌라 (IOI14_gondola) C++17
40 / 100
14 ms 1748 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);
	if (idx < 0) idx += n;
	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) assert(0);
	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) assert(0);
	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 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 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 1 ms 212 KB Output is correct
6 Correct 6 ms 936 KB Output is correct
7 Correct 12 ms 1232 KB Output is correct
8 Correct 9 ms 1648 KB Output is correct
9 Correct 4 ms 596 KB Output is correct
10 Correct 13 ms 1640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 7 ms 1000 KB Output is correct
7 Correct 12 ms 1232 KB Output is correct
8 Correct 8 ms 1584 KB Output is correct
9 Correct 5 ms 724 KB Output is correct
10 Correct 13 ms 1748 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 5 ms 908 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 13 ms 1652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 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 0 ms 212 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 3 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 0 ms 212 KB Output is correct
8 Correct 1 ms 292 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 12 ms 1664 KB Output is correct
10 Correct 9 ms 1108 KB Output is correct
11 Correct 4 ms 676 KB Output is correct
12 Correct 5 ms 852 KB Output is correct
13 Runtime error 2 ms 748 KB Execution killed with signal 6
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 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 14 ms 1668 KB Output is correct
10 Correct 9 ms 1120 KB Output is correct
11 Correct 4 ms 676 KB Output is correct
12 Correct 5 ms 932 KB Output is correct
13 Runtime error 2 ms 724 KB Execution killed with signal 6
14 Halted 0 ms 0 KB -