답안 #131844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131844 2019-07-17T19:43:22 Z shafinalam 사육제 (CEOI14_carnival) C++14
0 / 100
9 ms 376 KB
#include <bits/stdc++.h>

using namespace std;
int ans[1000];

int query(vector<int>v)
{
    int sz = v.size();
    cout << sz;
    for(int i : v) cout << ' ' << i;
    cout << endl;
    int x;
    cin >> x;
    return x;
}
int main()
{
    int n;
    cin >> n;
    vector<int>arr;

    arr.push_back(1);
    for(int i = 2; i <= n; i++)
    {
        vector<int>tmp = arr;
        tmp.push_back(i);
        if(query(tmp)==tmp.size()) arr = tmp;
    }
    for(int i = 0; i < arr.size(); i++) ans[arr[i]] = i+1;

    for(int i = 1; i <= n; i++)
    {
        if(ans[i]) continue;
        int lo = 0, hi = arr.size()-1, indx;

        while(lo<=hi)
        {
            int mid = (lo+hi)>>1;
            vector<int>tmp;
            tmp.push_back(i);
            for(int r = 0; r < mid; r++) tmp.push_back(arr[r]);
            if(query(tmp)==tmp.size())
            {
                indx = mid;
                lo = mid+1;
            }
            else hi = mid-1;
        }
        ans[i] = arr[indx];
    }

    cout << 0;
    for(int i = 1; i <= n; i++) cout << " " << ans[i];
    cout << endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:27:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(query(tmp)==tmp.size()) arr = tmp;
            ~~~~~~~~~~^~~~~~~~~~~~
carnival.cpp:29:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < arr.size(); i++) ans[arr[i]] = i+1;
                    ~~^~~~~~~~~~~~
carnival.cpp:42:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(query(tmp)==tmp.size())
                ~~~~~~~~~~^~~~~~~~~~~~
carnival.cpp:49:26: warning: 'indx' may be used uninitialized in this function [-Wmaybe-uninitialized]
         ans[i] = arr[indx];
                          ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 248 KB Integer 19 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 248 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 9 ms 248 KB Integer 11 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 248 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Incorrect 9 ms 248 KB Integer 22 violates the range [1, 17]
3 Halted 0 ms 0 KB -