답안 #131837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131837 2019-07-17T19:24:37 Z shafinalam 사육제 (CEOI14_carnival) C++14
0 / 100
8 ms 380 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 << '\n';
    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(), 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)==mid)
            {
                indx = mid;
                hi = mid-1;
            }
            else lo = mid+1;
        }
        ans[i] = arr[indx];
    }
    cout << 0;
    for(int i = 1; i <= n; i++) cout << " " << ans[i];
    cout << '\n';
    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:48:26: warning: 'indx' may be used uninitialized in this function [-Wmaybe-uninitialized]
         ans[i] = arr[indx];
                          ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 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 0 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 380 KB Integer 0 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 248 KB Integer 0 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 248 KB Integer 0 violates the range [1, 2]
2 Halted 0 ms 0 KB -