# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
645866 | TimDee | NoM (RMI21_nom) | C++17 | 1053 ms | 255952 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for (int i=0; i<n; ++i)
vector<vector<int>>v;
void bf(vector<int>&vis, int n, vector<int>&s) {
if (s.size()>=n) {
v.push_back(s);
return;
}
for (int i=1; i<=n; ++i) {
if (vis[i]) continue;
vis[i]=1;
s.push_back(i);
bf(vis,n,s);
vis[i]=0;
s.pop_back();
}
}
void solve() {
int n,m; cin>>n>>m;
if (n>5) return;
vector<int>vis(2*n+1,0);
vector<int>s;
bf(vis,2*n,s);
int ans=0;
for (auto a:v) {
int paiu=1;
forn(i,2*n) {
for (int k=i%m; k<2*n; k+=m) {
if (k==i) continue;
if (abs(a[k]-a[i])==n) paiu=0;
}
}
ans+=paiu;
}
cout<<ans;
}
int32_t main() {
solve();
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... |