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<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
ll mod;
int main(){
cin >> n >> mod;
ll ans = 0;
for(int i = 0; i < (1 << (2 * n)); i++){
vector<int> a, b;
for(int j = 0; j < 2 * n; j++){
if(i & (1 << j)) a.push_back(j);
else b.push_back(j);
}
if(a.size() != b.size()) continue;
do{
vector<pair<int, int>> vec;
bool flag = 1;
for(int k = 0; k < n; k++){
if(a[k] > b[k]){
flag = 0;
break;
}
vec.push_back(make_pair(a[k], b[k]));
}
if(!flag) continue;
int gre = 0, opt = 0;
int now = -1;
for(auto &[l, r]: vec){
if(now < l){
gre++;
now = r;
}
}
now = -1;
for(auto &[l, r]: vec){
if(now < l){
opt++;
now = r;
}
else now = min(now, r);
}
if(gre != opt) ans++;
//cout << gre << " " << opt << "\n";
}while(next_permutation(b.begin(), b.end()));
}
cout << ans % mod << "\n";
}
// g++ -std=gnu++20 pB.cpp -o run -Wall -Wextra -fsanitize=undefined -fsanitize=address
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |