Submission #918252

# Submission time Handle Problem Language Result Execution time Memory
918252 2024-01-29T13:50:37 Z HasanV11010238 Carnival (CEOI14_carnival) C++17
100 / 100
7 ms 696 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int coun(int l, int r, int ar[]){
    set<int> s;
    for (int i = l; i <= r; i++){
        s.insert(ar[i]);
    }
    return s.size();
}
string getstr(int l, int r){
    string ans = "";
    for (int i = l; i <= r; i++){
        ans += to_string(i) + " ";
    }
    return ans;
}
int main()
{
    int n, res, col = 2;
    cin>>n;
    int ar[n];
    ar[0] = 1;
    for (int i = 1; i < n; i++){
        cout<<(i + 1)<<" "<<getstr(1, i + 1)<<endl;
        cin>>res;
        int c = coun(0, i - 1, ar);
        if (res > c){
            ar[i] = col;
            col++;
            continue;
        }
        int l = 0, r = i - 1;
        while (true){
            int mid = (l + r) / 2;
            string s = getstr(l + 1, mid + 1) + to_string(i + 1);
            cout<<(mid - l + 2)<<" "<<s<<endl;
            cin>>res;
            c = coun(l, mid, ar);
            if (c == res){
                if (c == 1){
                    ar[i] = ar[l];
                    break;
                }
                else{
                    r = mid;
                }
            }
            else{
                l = mid + 1;
            }
        }
    }
    cout<<"0 ";
    for (int i = 0; i < n; i++){
        cout<<ar[i]<<' ';
    }
    cout<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 4 ms 436 KB Output is correct
3 Correct 3 ms 436 KB Output is correct
4 Correct 2 ms 696 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 4 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 432 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 7 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 4 ms 436 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 5 ms 432 KB Output is correct
6 Correct 4 ms 436 KB Output is correct
7 Correct 4 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 596 KB Output is correct
2 Correct 7 ms 436 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 692 KB Output is correct
5 Correct 5 ms 432 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 436 KB Output is correct
2 Correct 6 ms 432 KB Output is correct
3 Correct 5 ms 436 KB Output is correct
4 Correct 3 ms 688 KB Output is correct
5 Correct 4 ms 436 KB Output is correct
6 Correct 3 ms 436 KB Output is correct
7 Correct 2 ms 432 KB Output is correct