Submission #871106

#TimeUsernameProblemLanguageResultExecution timeMemory
871106MinaRagy06NoM (RMI21_nom)C++17
9 / 100
1057 ms596 KiB
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, m; cin >> n >> m; int a[2 * n]; for (int i = 0; i < n; i++) { a[i] = i + 1; } for (int i = 0; i < n; i++) { a[i + n] = - (i + 1); } sort(a, a + 2 * n); int cnt = 0; do { bool bad = 0; for (int i = 0; i < 2 * n; i++) { for (int j = i + 1; j < 2 * n; j++) { if (abs(a[i]) == abs(a[j])) { bad |= (j - i) % m == 0; } } } cnt += !bad; } while(next_permutation(a, a + 2 * n)); cout << cnt << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...