Submission #442161

# Submission time Handle Problem Language Result Execution time Memory
442161 2021-07-07T08:41:46 Z prvocislo Carnival (CEOI14_carnival) C++17
100 / 100
23 ms 336 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int maxn = 150;
bool ask(const vector<int> &v) // vrati ze ci maju nejaky dvaja ludia na tejto party rovnaky kostym
{
    cout << v.size();
    for (int i : v) cout << " " << i+1;
    cout << endl;
    int x; cin >> x;
    return x < v.size();
}
void answer(const vector<int> &v)
{
    cout << 0;
    for (int i : v) cout << " " << i+1;
    cout << endl;
}
vector<vector<int> > g(maxn);
vector<int> c;
void dfs(int u, int col)
{
    c[u] = col;
    for (int v : g[u]) if (c[v] == -1) dfs(v, col);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    while (ask(p))
    {
        int lo = 0, hi = p.size() - 1;
        while (lo < hi)
        {
            int mi = (lo + hi) >> 1;
            if (ask(vector<int>(p.begin(), p.begin() + mi + 1))) hi = mi;
            else lo = mi + 1;
        }
        int x = lo; lo = 0, hi = x - 1;
        while (lo < hi)
        {
            int mi = (lo + hi + 1) >> 1;
            if (ask(vector<int>(p.begin() + mi, p.begin() + x + 1))) lo = mi;
            else hi = mi - 1;
        }
        g[p[x]].push_back(p[lo]), g[p[lo]].push_back(p[x]);
        p.erase(p.begin() + x);
    }
    int col = 0; c.assign(n, -1);
    for (int i = 0; i < n; i++) if (c[i]==-1) dfs(i, col++);
    answer(c);
    return 0;
}

Compilation message

carnival.cpp: In function 'bool ask(const std::vector<int>&)':
carnival.cpp:12:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     return x < v.size();
      |            ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 308 KB Output is correct
2 Correct 19 ms 200 KB Output is correct
3 Correct 11 ms 336 KB Output is correct
4 Correct 2 ms 312 KB Output is correct
5 Correct 13 ms 316 KB Output is correct
6 Correct 11 ms 200 KB Output is correct
7 Correct 14 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 316 KB Output is correct
2 Correct 23 ms 296 KB Output is correct
3 Correct 8 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 18 ms 296 KB Output is correct
6 Correct 17 ms 308 KB Output is correct
7 Correct 19 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 200 KB Output is correct
2 Correct 14 ms 200 KB Output is correct
3 Correct 19 ms 200 KB Output is correct
4 Correct 2 ms 200 KB Output is correct
5 Correct 15 ms 200 KB Output is correct
6 Correct 16 ms 200 KB Output is correct
7 Correct 19 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 312 KB Output is correct
2 Correct 19 ms 316 KB Output is correct
3 Correct 8 ms 316 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 18 ms 300 KB Output is correct
6 Correct 12 ms 312 KB Output is correct
7 Correct 21 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 200 KB Output is correct
2 Correct 16 ms 312 KB Output is correct
3 Correct 8 ms 316 KB Output is correct
4 Correct 12 ms 200 KB Output is correct
5 Correct 14 ms 200 KB Output is correct
6 Correct 7 ms 312 KB Output is correct
7 Correct 3 ms 200 KB Output is correct