# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1124603 | Zero_OP | NoM (RMI21_nom) | C++20 | 266 ms | 440 KiB |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define sz(v) (int)v.size()
#define dbg(x) "[" #x " = " << (x) << "]"
#define all(v) begin(v), end(v)
#define compact(v) v.erase(unique(all(v)), end(v))
#define file(name) if(fopen(name".inp", "r")){ freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
template<typename T>
bool minimize(T& a, const T& b){
if(a > b){
return a = b, true;
}
return false;
}
template<typename T>
bool maximize(T& a, const T& b){
if(a < b){
return a = b, true;
}
return false;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1e9 + 7;
int N, M;
namespace subtask1{
bool check(){
return N <= 5 && M <= 5;
}
void solve(){
vector<int> perm(2 * N);
iota(all(perm), 0);
int ans = 0;
do{
vector<int> lst(N, -1);
bool ok = true;
for(int i = 0; i < 2 * N; ++i){
int x = perm[i] % N;
if(lst[x] == -1) lst[x] = i;
else if(abs(lst[x] - i) % M == 0){
ok = false;
break;
}
}
ans += ok;
} while(next_permutation(all(perm)));
cout << ans << '\n';
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
file("A");
cin >> N >> M;
if(subtask1::check()) return subtask1::solve(), 0;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |