Submission #775242

# Submission time Handle Problem Language Result Execution time Memory
775242 2023-07-06T08:59:14 Z 박영우(#9988) Festivals in JOI Kingdom 2 (JOI23_festival2) C++17
10 / 100
9000 ms 316 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 310
#define MAXS 22
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
int N;
int nxt[MAX];
int ans = 0;
ll MOD;
void calc(int lv) {
	if (lv > N * 2) {
		int i;
		vector<pii> vpi;
		int cnt, e;
		cnt = e = 0;
		for (i = 1; i <= N * 2; i++) {
			if (i < nxt[i]) {
				vpi.emplace_back(i, nxt[i]);
				if (e < i) e = nxt[i], cnt++;
			}
		}
		sort(vpi.begin(), vpi.end(), [&](pii p1, pii p2) {return p1.second < p2.second; });
		e = 0;
		int cnt2 = 0;
		for (auto& [a, b] : vpi) if (e < a) cnt2++, e = b;
		if (cnt != cnt2) ans++;
		return;
	}
	if (nxt[lv]) {
		calc(lv + 1);
		return;
	}
	int i;
	for (i = lv + 1; i <= N * 2; i++) {
		if (!nxt[i]) {
			nxt[lv] = i;
			nxt[i] = lv;
			calc(lv + 1);
			nxt[lv] = nxt[i] = 0;
		}
	}
}
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> N >> MOD;
	calc(1);
	cout << ans << ln;
}
# 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 1 ms 212 KB Output is correct
7 Correct 1 ms 316 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 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 592 ms 304 KB Output is correct
9 Correct 594 ms 308 KB Output is correct
10 Correct 603 ms 300 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 37 ms 212 KB Output is correct
13 Correct 37 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 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 592 ms 304 KB Output is correct
9 Correct 594 ms 308 KB Output is correct
10 Correct 603 ms 300 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 37 ms 212 KB Output is correct
13 Correct 37 ms 212 KB Output is correct
14 Execution timed out 9049 ms 212 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 592 ms 304 KB Output is correct
9 Correct 594 ms 308 KB Output is correct
10 Correct 603 ms 300 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 37 ms 212 KB Output is correct
13 Correct 37 ms 212 KB Output is correct
14 Execution timed out 9049 ms 212 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 592 ms 304 KB Output is correct
9 Correct 594 ms 308 KB Output is correct
10 Correct 603 ms 300 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 37 ms 212 KB Output is correct
13 Correct 37 ms 212 KB Output is correct
14 Execution timed out 9049 ms 212 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 592 ms 304 KB Output is correct
9 Correct 594 ms 308 KB Output is correct
10 Correct 603 ms 300 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 37 ms 212 KB Output is correct
13 Correct 37 ms 212 KB Output is correct
14 Execution timed out 9049 ms 212 KB Time limit exceeded
15 Halted 0 ms 0 KB -