답안 #86972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86972 2018-11-29T02:29:48 Z antimirage 곤돌라 (IOI14_gondola) C++17
90 / 100
27 ms 4820 KB
#include "gondola.h"
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 3e5 + 5, mod = 1e9 + 9;

int u[N], sz, mx, pos, ind[N], ar[N], n, fl;

deque <pair <int, int> > vec;

int valid(int N, int x[])
{
	n = N;
	for (int i = 0; i < n; i++)
	{
		if (u[x[i]] > 0)
			return 0;
		u[x[i]] = i + 1;
	}
	for (int i = 1; i < n; i++)	
	{
		if ( u[i] != 0 && u[i + 1] != 0 && ((u[i] - 1) + 1) % n != u[i + 1] - 1)
			return 0;
	}
	if ( u[n] != 0 && u[1] != 0 && ((u[n] - 1) + 1) % n != u[1] - 1)
		return 0;
		
	return 1;
}	
int replacement(int n, int a[], int ans[])
{
	for (int i = 0; i < n; i++)
		mx = max(a[i], mx);
		
	for (int i = 0; i < n; i++)
	{
		if(a[i] > n)
			vec.pb( mk(a[i], i) );
		else
			pos = (i - (a[i] - 1) + n) % n;
	}
	sort( all(vec) );
	ind[pos] = ++sz;
	
	for (int i = (pos + 1) % n; i != pos; i = (i + 1) % n)
		ind[i] = ++sz;
	
	sz = 0;
	for (int i = n + 1; i <= mx; i++)
	{
		ans[sz++] = ind[ vec[0].second ];
		ind[ vec[0].second ] = i;
		if ( vec[0].first == i )
			vec.pop_front();
	}
	return sz;
}	
int countReplacement(int n, int a[])
{
	long long ans = 1;
	if (valid(n, a) == 0)
		return 0;
		
	for (int i = 0; i < n; i++)
		mx = max(a[i], mx);
		
	for (int i = 0; i < n; i++)
	{
		if(a[i] > n)
			vec.pb( mk(a[i], i) );
		else
			pos = (i - (a[i] - 1) + n) % n, fl = 1;
	}
	sort( all(vec) );
	
	sz = 0;
	for (int i = n + 1; i <= mx; i++)
	{
		if ( vec[0].first == i )
			vec.pop_front();
		else
			ans *= (int)vec.size(),
			ans %= mod;
	}
	if (!fl)
		ans *= n, ans %= mod;
	return ans;
}
/**
4
3
3 1 4
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 3 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 672 KB Output is correct
2 Correct 2 ms 672 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
4 Correct 2 ms 672 KB Output is correct
5 Correct 2 ms 672 KB Output is correct
6 Correct 14 ms 872 KB Output is correct
7 Correct 15 ms 1256 KB Output is correct
8 Correct 11 ms 1256 KB Output is correct
9 Correct 5 ms 1256 KB Output is correct
10 Correct 16 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1260 KB Output is correct
2 Correct 2 ms 1260 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 2 ms 1260 KB Output is correct
5 Correct 2 ms 1260 KB Output is correct
6 Correct 7 ms 1260 KB Output is correct
7 Correct 17 ms 1260 KB Output is correct
8 Correct 12 ms 1260 KB Output is correct
9 Correct 5 ms 1260 KB Output is correct
10 Correct 13 ms 1276 KB Output is correct
11 Correct 2 ms 1276 KB Output is correct
12 Correct 2 ms 1276 KB Output is correct
13 Correct 13 ms 1532 KB Output is correct
14 Correct 2 ms 1532 KB Output is correct
15 Correct 16 ms 1532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1532 KB Output is correct
2 Correct 2 ms 1532 KB Output is correct
3 Correct 2 ms 1532 KB Output is correct
4 Correct 2 ms 1532 KB Output is correct
5 Correct 2 ms 1532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1532 KB Output is correct
2 Correct 2 ms 1532 KB Output is correct
3 Correct 2 ms 1532 KB Output is correct
4 Correct 2 ms 1532 KB Output is correct
5 Correct 2 ms 1532 KB Output is correct
6 Correct 2 ms 1532 KB Output is correct
7 Correct 3 ms 1532 KB Output is correct
8 Correct 3 ms 1532 KB Output is correct
9 Correct 3 ms 1532 KB Output is correct
10 Correct 3 ms 1532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1532 KB Output is correct
2 Correct 2 ms 1532 KB Output is correct
3 Correct 2 ms 1532 KB Output is correct
4 Correct 2 ms 1532 KB Output is correct
5 Correct 2 ms 1532 KB Output is correct
6 Correct 2 ms 1532 KB Output is correct
7 Correct 2 ms 1532 KB Output is correct
8 Correct 3 ms 1532 KB Output is correct
9 Correct 2 ms 1532 KB Output is correct
10 Correct 2 ms 1532 KB Output is correct
11 Correct 13 ms 1532 KB Output is correct
12 Correct 16 ms 1532 KB Output is correct
13 Correct 20 ms 1852 KB Output is correct
14 Correct 14 ms 1852 KB Output is correct
15 Correct 24 ms 2620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2620 KB Output is correct
2 Correct 2 ms 2620 KB Output is correct
3 Correct 2 ms 2620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2620 KB Output is correct
2 Correct 2 ms 2620 KB Output is correct
3 Correct 2 ms 2620 KB Output is correct
4 Correct 2 ms 2620 KB Output is correct
5 Correct 2 ms 2620 KB Output is correct
6 Correct 2 ms 2620 KB Output is correct
7 Correct 2 ms 2620 KB Output is correct
8 Correct 2 ms 2620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2620 KB Output is correct
2 Correct 2 ms 2620 KB Output is correct
3 Correct 2 ms 2620 KB Output is correct
4 Correct 2 ms 2620 KB Output is correct
5 Correct 2 ms 2620 KB Output is correct
6 Correct 2 ms 2620 KB Output is correct
7 Correct 2 ms 2620 KB Output is correct
8 Correct 2 ms 2620 KB Output is correct
9 Correct 22 ms 2688 KB Output is correct
10 Correct 20 ms 2800 KB Output is correct
11 Correct 10 ms 2800 KB Output is correct
12 Correct 11 ms 2800 KB Output is correct
13 Correct 6 ms 2800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2800 KB Output is correct
2 Correct 2 ms 2800 KB Output is correct
3 Correct 2 ms 2800 KB Output is correct
4 Correct 2 ms 2800 KB Output is correct
5 Correct 2 ms 2800 KB Output is correct
6 Correct 2 ms 2800 KB Output is correct
7 Correct 2 ms 2800 KB Output is correct
8 Correct 2 ms 2800 KB Output is correct
9 Correct 24 ms 3960 KB Output is correct
10 Correct 27 ms 3960 KB Output is correct
11 Correct 10 ms 3960 KB Output is correct
12 Correct 11 ms 4016 KB Output is correct
13 Correct 8 ms 4016 KB Output is correct
14 Runtime error 17 ms 4820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Halted 0 ms 0 KB -