Submission #1029318

# Submission time Handle Problem Language Result Execution time Memory
1029318 2024-07-20T16:19:51 Z 0pt1mus23 Lutrija (COCI19_lutrija) C++14
0 / 70
41 ms 348 KB
#pragma GCC optimize("O3", "inline")
#define skillissue <bits/stdc++.h>
#define ultra_mal std
#include skillissue
using namespace ultra_mal;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ins insert
#define pb push_back
#define int long long int
#define pii pair<int, int>
#define endl '\n' 
#define drop(x) cout<<(x)<<endl; return;
#define all(x) x.begin(),x.end()
#define hash FhashF
const int mod = 1e9 +7, sze = 1E3 +100, inf = LLONG_MAX, P = 1453;
// const int L = 30;

int prime(int aa){
    for(int i = 2;i*i<=aa;i++){
        if(aa%i==0){
            return 0;        
        }
    }

    return 1;
}

void cave(){
    int x,y;
    cin>>x>>y;
    vector<int> lst2={x+2,x-2,y-2,y+2};
    vector<int> lst;
    for(auto v:lst2){
        if(prime(v) && v!=x && v!=y && v>0){
            lst.pb(v);
        }
    }
    
    int n= lst.size();
    for(int i=0;i<(1<<n);i++){
        vector<int> arr;
        for(int j=0;j<n;j++){
            if(i & (1<<j)){
                arr.pb(lst[j]);
            }
        }

        do{
            vector<int> ans;
            ans.pb(x);
            for(auto v:arr){
                ans.pb(v);
            }
            ans.pb(y);
            int m = ans.size();
            bool flag=true;
            for(int i =0;i+1<m;i++){
                if(!prime(abs(ans[i]-ans[i+1]))){
                    flag=false;
                    break;
                }
            }
            if(flag){
                cout<<ans.size()<<endl;
                for(auto v:ans){
                    cout<<v<<" ";
                }
                cout<<endl;
                return;
            }
        }while(next_permutation(all(arr)));
    }

    drop(-1);

    
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int tt = 1;
    // cin>>tt;
    
    while(tt--){
        cave();
    }

    return 0;
} 
 
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -