Submission #908880

# Submission time Handle Problem Language Result Execution time Memory
908880 2024-01-17T01:05:46 Z vjudge1 Carnival (CEOI14_carnival) C++17
0 / 100
15 ms 444 KB
#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 time Memory Grader output
1 Incorrect 11 ms 444 KB Integer 15 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 344 KB Integer 10 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 344 KB Output is correct
2 Incorrect 10 ms 344 KB Integer 10 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 340 KB Integer 18 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 344 KB Output is correct
2 Incorrect 12 ms 344 KB Integer 19 violates the range [1, 17]
3 Halted 0 ms 0 KB -