Submission #895738

# Submission time Handle Problem Language Result Execution time Memory
895738 2023-12-30T17:55:53 Z Aiperiii Festivals in JOI Kingdom 2 (JOI23_festival2) C++14
5 / 100
9000 ms 452 KB
#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

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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Execution timed out 9050 ms 348 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Execution timed out 9050 ms 348 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Execution timed out 9050 ms 348 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Execution timed out 9050 ms 348 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Execution timed out 9050 ms 348 KB Time limit exceeded
9 Halted 0 ms 0 KB -