Submission #895738

#TimeUsernameProblemLanguageResultExecution timeMemory
895738AiperiiiFestivals in JOI Kingdom 2 (JOI23_festival2)C++14
5 / 100
9050 ms452 KiB
#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)

festival2.cpp: In function 'int main()':
festival2.cpp:50:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |                         for(int j=1;j<d.size();j++){
      |                                     ~^~~~~~~~~
festival2.cpp:31:25: warning: variable 'l' set but not used [-Wunused-but-set-variable]
   31 |                     int l=v1[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...
#Verdict Execution timeMemoryGrader output
Fetching results...