Submission #1029319

#TimeUsernameProblemLanguageResultExecution timeMemory
10293190pt1mus23Lutrija (COCI19_lutrija)C++14
14 / 70
58 ms348 KiB
#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; lst2.pb(2); 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 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...