Submission #739271

# Submission time Handle Problem Language Result Execution time Memory
739271 2023-05-10T09:21:31 Z NeroZein Gondola (IOI14_gondola) C++17
45 / 100
11 ms 4544 KB
#include "gondola.h"
#include <bits/stdc++.h> 
using namespace std; 

const int M = (int) 1e6 + 1;
const int md = (int) 1e9 + 9; 

int mx; 
bitset<M> vis;

int valid(int n, int inputSeq[]) {
	for (int i = 0; i < n; ++i) {
		if (vis[inputSeq[i]] == true) {
			return false; 
		}
		mx = max(mx, inputSeq[i]);
		vis[inputSeq[i]] = true;
	}
	function<bool(int, int, int)> Go = [&](int id, int cur, int step) {
		if (id < 0 || id >= n) {
			return true; 
		}
		if (cur == 0) cur = n; 
		if (cur == n + 1) cur = 1; 
		if (inputSeq[id] <= n && inputSeq[id] != cur) {
			return false; 
		}
		return Go(id + step, cur + step, step); 
	}; 
	bool ret = true; 
  for (int i = 0; i < n; ++i) {
		if (inputSeq[i] <= n) {
			ret &= Go(i, inputSeq[i], 1);
			vis[inputSeq[i]] = 0;  
			ret &= Go(i, inputSeq[i], -1); 
			break; 
		}
	}
	return ret;
}

int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
  for (int i = 0; i < n; ++i) {
		mx = max(mx, gondolaSeq[i]); 
	}
	for (int i = 0; i < n; ++i) {
		vis[gondolaSeq[i]] = true; 
	}  
	int ans = 0; 
	for (int i = 1; i <= mx; ++i) {
		if (!vis[i]) {
			replacementSeq[ans++] = i;  
		}
	}
	return ans; 
}

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

int countReplacement(int n, int inputSeq[]) {
  if (!valid(n, inputSeq)) {
		return 0; 
	}
	int ans = 1;
	int cnt = 0;  
	for (int i = mx; i > n; --i) {
		if (vis[i]) {
			cnt++; 
			continue; 
		}
		ans = (long long) ans * cnt % md; 
	}
	return ans; 
}
# 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
# 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 4 ms 2224 KB Output is correct
7 Correct 9 ms 644 KB Output is correct
8 Correct 8 ms 3924 KB Output is correct
9 Correct 3 ms 1364 KB Output is correct
10 Correct 9 ms 4436 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 4 ms 2132 KB Output is correct
7 Correct 8 ms 596 KB Output is correct
8 Correct 9 ms 3924 KB Output is correct
9 Correct 3 ms 1364 KB Output is correct
10 Correct 9 ms 4436 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 4 ms 436 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 8 ms 668 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
# 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 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 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 0 ms 212 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 312 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 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 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 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 316 KB Output is correct
9 Correct 11 ms 4436 KB Output is correct
10 Correct 10 ms 3776 KB Output is correct
11 Correct 4 ms 1364 KB Output is correct
12 Correct 4 ms 1876 KB Output is correct
13 Incorrect 2 ms 320 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 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 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 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 10 ms 4544 KB Output is correct
10 Correct 9 ms 3776 KB Output is correct
11 Correct 4 ms 1476 KB Output is correct
12 Correct 4 ms 1860 KB Output is correct
13 Incorrect 2 ms 340 KB Output isn't correct
14 Halted 0 ms 0 KB -