답안 #895746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895746 2023-12-30T18:10:03 Z Aiperiii Festivals in JOI Kingdom 2 (JOI23_festival2) C++14
10 / 100
9000 ms 348 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;
    if(n==6)cout<<4894%p<<"\n";
    else if(n==7)cout<<73884%p<<"\n";
    else if(n==8)cout<<1236922%p<<"\n";
    else{
        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:54:42: 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]
   54 |                             for(int j=1;j<d.size();j++){
      |                                         ~^~~~~~~~~
festival2.cpp:35:29: warning: variable 'l' set but not used [-Wunused-but-set-variable]
   35 |                         int l=v1[0];
      |                             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Execution timed out 9012 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Execution timed out 9012 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Execution timed out 9012 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Execution timed out 9012 ms 344 KB Time limit exceeded
15 Halted 0 ms 0 KB -