Submission #908880

#TimeUsernameProblemLanguageResultExecution timeMemory
908880vjudge1Carnival (CEOI14_carnival)C++17
0 / 100
15 ms444 KiB
#include<bits/stdc++.h> using namespace std; int n; int ans[160]; vector<int>primos; bool vis[200005]; int b[160]; void criba(){ for(int i=2; i<200; i++){ if(!vis[i]){ primos.push_back(i); for(int j=i*i; j<=200; j+=i)vis[j]=1; } } } int main(){ cin >> n; int x; int cont=1; int crep=0; int dif; primos.push_back(1); criba(); cout << n << " "; for(int i=1; i<=n; i++){ cout << i; if(i==n)cout << endl; else cout << " "; }cin >> dif; for(auto i:primos){ for(int j=1; j+i<=n; j++){ cout << 2 << " " << j << " " << j+i << endl; crep++; cin >> x; if(x==1){ if(ans[j] && ans[j+i]){ ans[j] =min(ans[j], ans[j+i]); ans[j+i] = ans[j]; } else{ if(ans[j])ans[j+i] = ans[j]; else if(ans[j+i])ans[j] = ans[j+i]; else { ans[j] = cont; ans[j+i] = cont; } } cont++; }else{ if(ans[j]==0) ans[j] = cont++; if(ans[j+i]==0)ans[j+i] = cont++; } } }set<int> st; for(int i=1; i<=n; i++){ st.insert(ans[i]); } for(int i=1; i<=n; i++){ if(!b[ans[i]]){ int ind = ans[i]; if(ans[i]>dif)while(ans[i]>dif && st.count(ans[i]))ans[i]--; b[ind] = ans[i]; st.insert(ans[i]); }else ans[i] = b[ans[i]]; } cout << 0 << " "; for(int i=1; i<=n; i++)cout << ans[i] << " "; cout << endl; 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...