Submission #649199

#TimeUsernameProblemLanguageResultExecution timeMemory
649199boris_mihovNoM (RMI21_nom)C++17
0 / 100
0 ms212 KiB
#include <algorithm> #include <iostream> #include <numeric> #include <vector> #include <set> typedef long long llong; const int MAXN = 2000 + 10; const int MOD = 1e9 + 7; const int INF = 1e9; int n, m; int perm[MAXN]; int pos[MAXN]; void solve() { int ans = 0; for (int i = 1 ; i <= n ; ++i) { perm[2*i - 1] = i; perm[2*i] = i; } do { bool valid = true; std::fill(pos + 1, pos + 1 + n, 0); for (int i = 1 ; i <= 2*n ; ++i) { if (pos[perm[i]] == 0) { pos[perm[i]] = i; } else { if ((i - pos[perm[i]]) % m == 0) { valid = false; break; } } } ans += valid; } while(std::next_permutation(perm + 1, perm + 1 + 2*n)); std::cout << ans << '\n'; } void read() { std::cin >> n >> m; } void fastIO() { std::ios_base :: sync_with_stdio(0); std::cout.tie(nullptr); std::cin.tie(nullptr); } int main() { fastIO(); read(); solve(); 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...