답안 #752644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
752644 2023-06-03T11:11:12 Z benjaminkleyn 사육제 (CEOI14_carnival) C++17
0 / 100
5 ms 208 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n;
bool done[150];
int val[150];

int query(const vector<int> &peoples, int l = 0, int r = 149, int extra = -1)
{
    cout << min((int)peoples.size(), r + 1) - l + (extra != -1);
    for (int i = l; i <= r && i < peoples.size(); i++)
        cout << ' ' << peoples[i] + 1;
    if (extra != -1)
        cout << ' ' << extra + 1;
    cout << '\n';

    cout.flush();
    int result;
    cin >> result;
    return result;
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);

    cin >> n;

    vector<int> a = {0};
    done[0] = true;
    int cur = 1;
    for (int i = 1; i < n; i++)
    {
        a.push_back(i);
        if (query(a) > cur)
            cur++, done[i] = true;
        else
            a.pop_back();
    }

    int c = 0;
    for (int i : a)
        val[i] = c++;

    for (int i = 0; i < n; i++)
        if (!done[i])
        {
            // binary search in a to find the same costume.
            int lo = 0, hi = c - 1, mid;
            while (lo < hi)
            {
                mid = (lo + hi) / 2;
                if (query(a, lo, mid, i) == mid - lo + 1)
                    hi = mid;
                else
                    lo = mid + 1;
            }
            val[i] = val[a[lo]];
        }

    for (int i = 0; i < n; i++)
        cout << val[i] + 1 << ' ';
    cout << '\n';

    return 0;
}

Compilation message

carnival.cpp: In function 'int query(const std::vector<int>&, int, int, int)':
carnival.cpp:12:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = l; i <= r && i < peoples.size(); i++)
      |                               ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 208 KB Same person came twice to the party.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 208 KB Same person came twice to the party.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 208 KB Same person came twice to the party.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 208 KB Same person came twice to the party.
2 Halted 0 ms 0 KB -