Submission #796784

# Submission time Handle Problem Language Result Execution time Memory
796784 2023-07-28T18:06:02 Z GusterGoose27 Festivals in JOI Kingdom 2 (JOI23_festival2) C++17
10 / 100
647 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

int n, mod;

bool chosen[16];
int ans = 0;

bool works(vector<pii> &v) {
	vector<pii> s, t;
	for (int i = 0; i < n; i++) {
		s.push_back(pii(v[i].first, i));
		t.push_back(pii(v[i].second, i));
	}
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	int a = 0, b = 0;
	int r = -1;
	for (int i = 0; i < n; i++) {
		if (s[i].first < r) continue;
		a++;
		r = v[s[i].second].second;
	}
	r = -1;
	for (int i = 0; i < n; i++) {
		if (v[t[i].second].first < r) continue;
		b++;
		r = t[i].first;
	}
	return b > a;
}

void make(vector<pii> &v, int cur = 0) {
	if (cur == n) {
		ans += works(v);
		return;
	}
	for (int i = 0; i < 2*n; i++) {
		if (chosen[i]) continue;
		chosen[i] = 1;
		for (int j = i+1; j < 2*n; j++) {
			if (chosen[j]) continue;
			chosen[j] = 1;
			v.push_back(pii(i, j));
			make(v, cur+1);
			v.pop_back();
			chosen[j] = 0;
		}
		chosen[i] = 0;
		return;
	}
}

int main() {
	cin >> n >> mod;
	assert(n <= 8);
	vector<pii> v;
	make(v);
	cout << ans%mod << '\n';
}
# 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 0 ms 240 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 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 0 ms 240 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 212 KB Output is correct
8 Correct 644 ms 280 KB Output is correct
9 Correct 646 ms 212 KB Output is correct
10 Correct 647 ms 332 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 40 ms 212 KB Output is correct
13 Correct 40 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 0 ms 240 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 212 KB Output is correct
8 Correct 644 ms 280 KB Output is correct
9 Correct 646 ms 212 KB Output is correct
10 Correct 647 ms 332 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 40 ms 212 KB Output is correct
13 Correct 40 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 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 0 ms 240 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 212 KB Output is correct
8 Correct 644 ms 280 KB Output is correct
9 Correct 646 ms 212 KB Output is correct
10 Correct 647 ms 332 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 40 ms 212 KB Output is correct
13 Correct 40 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 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 0 ms 240 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 212 KB Output is correct
8 Correct 644 ms 280 KB Output is correct
9 Correct 646 ms 212 KB Output is correct
10 Correct 647 ms 332 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 40 ms 212 KB Output is correct
13 Correct 40 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 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 0 ms 240 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 212 KB Output is correct
8 Correct 644 ms 280 KB Output is correct
9 Correct 646 ms 212 KB Output is correct
10 Correct 647 ms 332 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 40 ms 212 KB Output is correct
13 Correct 40 ms 212 KB Output is correct
14 Runtime error 1 ms 340 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -