Submission #738435

# Submission time Handle Problem Language Result Execution time Memory
738435 2023-05-08T18:45:13 Z LucaGreg Carnival (CEOI14_carnival) C++17
100 / 100
29 ms 316 KB
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define int long long int
 
const int INF = 2000000000000000;
const int mod = 1000000007;

int marc[210];
int n;

int bb(int id, int ini, int fim){
    vector<int> query;
    for(int i=ini;i<=fim;i++) if(marc[i]==0) query.pb(i);
    if(query.empty()) return -1;
    cout<<query.size()<<" ";
    for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" ";
    cout<<"\n";
    cout.flush();
    int qtd; cin>>qtd;
    query.pb(id);
    cout<<query.size()<<" ";
    for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" ";
    cout<<"\n";
    cout.flush();
    int qtdId; cin>>qtdId;
    if(qtdId>qtd) return -1;
    while(ini<fim){
        query.clear();
        int m = (ini + fim)/2;
        for(int i=ini;i<=m;i++) if(marc[i]==0) query.pb(i);
        if(query.empty()){
            ini = m + 1;
            continue;
        }
        cout<<query.size()<<" ";
        for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" ";
        cout<<"\n";
        cout.flush();
        int auxQtd; cin>>auxQtd;
        query.pb(id);
        cout<<query.size()<<" ";
        for(int i=0;i<(int)query.size();i++) cout<<query[i]<<" ";
        cout<<"\n";
        cout.flush();
        int auxQtdId; cin>>auxQtdId;
        if(auxQtdId>auxQtd) ini = m + 1;
        else fim = m;
    }
    return fim;
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(0);
    cin>>n;
    int curType = 1;
    for(int i=1;i<=n;i++){
        if(marc[i]!=0) continue;
        marc[i] = curType;
        while(true){
            int id = bb(i, i + 1, n);
            if(id==-1) break;
            marc[id] = curType;
        }
        curType++;
    }
    cout<<0<<" ";
    for(int i=1;i<=n;i++) cout<<marc[i]<<" ";
    cout<<"\n";
 
    return 0;
}

Compilation message

carnival.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   58 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 26 ms 208 KB Output is correct
2 Correct 17 ms 212 KB Output is correct
3 Correct 9 ms 212 KB Output is correct
4 Correct 4 ms 316 KB Output is correct
5 Correct 20 ms 208 KB Output is correct
6 Correct 15 ms 208 KB Output is correct
7 Correct 15 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 208 KB Output is correct
2 Correct 21 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 17 ms 208 KB Output is correct
6 Correct 21 ms 208 KB Output is correct
7 Correct 24 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 208 KB Output is correct
2 Correct 17 ms 208 KB Output is correct
3 Correct 17 ms 208 KB Output is correct
4 Correct 6 ms 316 KB Output is correct
5 Correct 19 ms 208 KB Output is correct
6 Correct 17 ms 208 KB Output is correct
7 Correct 29 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 208 KB Output is correct
2 Correct 24 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 28 ms 288 KB Output is correct
6 Correct 12 ms 208 KB Output is correct
7 Correct 16 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 208 KB Output is correct
2 Correct 24 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 18 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 15 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct