# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895738 | Aiperiii | Festivals in JOI Kingdom 2 (JOI23_festival2) | C++14 | 9050 ms | 452 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>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,p;
cin>>n>>p;
int ans=0;
for(int i=0;i<(1<<(n*2));i++){
vector <int> v1,v2;
for(int j=0;j<n*2;j++){
if((i & (1<<j))!=0)v1.pb(j);
else v2.pb(j);
}
if(v1.size()==v2.size()){
do{
bool flag=true;
for(int j=0;j<n;j++){
if(v1[j]>v2[j])flag=false;
}
if(flag){
int cnt1=1;
int l=v1[0];
int r=v2[0];
for(int j=1;j<n;j++){
if(v1[j]>r){
cnt1++;
l=v1[j];
r=v2[j];
}
}
int cnt2=0;
for(int x=0;x<(1<<n);x++){
vector <pair <int,int> > d;
bool can=1;
for(int y=0;y<n;y++){
if((x & (1<<y))!=0){
d.pb({v1[y],v2[y]});
}
}
for(int j=1;j<d.size();j++){
if(d[j].ff<d[j-1].ss){
can=0;break;
}
}
if(can)cnt2=max((int)d.size(),cnt2);
}
if(cnt1<cnt2){
ans++;ans%=p;
}
}
}while(next_permutation(all(v2)));
}
}
cout<<ans<<"\n";
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |