#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, M;
cin >> N >> M;
for (int i = 1; i <= 2*N; i++) v.push_back(i);
int resp = 0;
do
{
bool b = true;
for (int i = 0; i < 2*N; i++)
{
for (int j = 0; j < 2*N; j++)
{
if (abs(v[j] - v[i]) != N) continue;
if ((j - i) % M == 0) b = false;
}
}
resp += b;
}
while (next_permutation(v.begin(), v.end()));
cout << resp;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
324 KB |
Output is correct |
3 |
Correct |
0 ms |
212 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 |
7 ms |
320 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Execution timed out |
921 ms |
300 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
324 KB |
Output is correct |
3 |
Correct |
0 ms |
212 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 |
7 ms |
320 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Execution timed out |
921 ms |
300 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
324 KB |
Output is correct |
3 |
Correct |
0 ms |
212 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 |
7 ms |
320 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Execution timed out |
921 ms |
300 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
324 KB |
Output is correct |
3 |
Correct |
0 ms |
212 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 |
7 ms |
320 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Execution timed out |
921 ms |
300 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
324 KB |
Output is correct |
3 |
Correct |
0 ms |
212 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 |
7 ms |
320 KB |
Output is correct |
8 |
Correct |
7 ms |
212 KB |
Output is correct |
9 |
Execution timed out |
921 ms |
300 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |