QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202881 | #5532. Kangaroo | Camillus# | 0 | 1ms | 3472kb | C++20 | 1.2kb | 2023-10-06 13:55:47 | 2024-07-04 02:16:58 |
answer
#include <bits/stdc++.h>
using namespace std;
signed main() {
#ifndef LOCAL
ios::sync_with_stdio(false);
cin.tie(nullptr);
#else
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, s, f;
cin >> n >> s >> f;
s--, f--;
vector<int> p(n);
iota(p.begin(), p.end(), 0);
int cnt = 0;
do {
bool ok = true;
for (int i = 0; i < n; i++) {
if (p[i] == i) {
ok = false;
}
}
if (!ok) {
continue;
}
int x = 0;
int y = p[x];
int c = 1;
while (y != x) {
y = p[y];
c++;
}
if (c != n) {
continue;
}
for (int i = 0; i < n; i++) {
if (i == f) {
continue;
}
if (p[i] < i) {
ok &= p[p[i]] > p[i];
}
if (p[i] > i) {
ok &= p[p[i]] < p[i];
}
}
cnt += ok;
} while (next_permutation(p.begin(), p.end()));
cout << cnt << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3472kb
input:
7 3 6
output:
45
result:
wrong answer 1st numbers differ - expected: '14', found: '45'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%