답안 #164889

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164889 2019-11-24T02:30:10 Z arnold518 사육제 (CEOI14_carnival) C++14
100 / 100
32 ms 568 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 150;

int N, ans[MAXN+10], cnt;
map<vector<int>, int> M;

int ask(vector<int> V)
{
    if(M.find(V)!=M.end()) return M[V];
    printf("%d ", V.size());
    for(auto it : V) printf("%d ", it); printf("\n");
    fflush(stdout);

    int t;
    scanf("%d", &t);
    M[V]=t;
    return t;
}

bool query(int l, int r, int k)
{
    int i;
    vector<int> V1, V2;
    for(i=l; i<=r; i++) V1.push_back(i), V2.push_back(i);
    V2.push_back(k);
    return ask(V1)==ask(V2);
}

int main()
{
    int i, j;

    scanf("%d", &N);
    ans[1]=1; cnt=2;
    for(i=2; i<=N; i++)
    {
        if(!query(1, i-1, i)) ans[i]=cnt++;
        else
        {
            int lo=1, hi=i-1;
            while(lo<hi)
            {
                int mid=lo+hi>>1;
                if(query(lo, mid, i)) hi=mid;
                else lo=mid+1;
            }
            ans[i]=ans[lo];
        }
    }
    printf("0 ");
    for(i=1; i<=N; i++) printf("%d ", ans[i]);
}

Compilation message

carnival.cpp: In function 'int ask(std::vector<int>)':
carnival.cpp:16:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d ", V.size());
                   ~~~~~~~~^
carnival.cpp:17:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(auto it : V) printf("%d ", it); printf("\n");
     ^~~
carnival.cpp:17:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(auto it : V) printf("%d ", it); printf("\n");
                                         ^~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:49:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
                 int mid=lo+hi>>1;
                         ~~^~~
carnival.cpp:37:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
carnival.cpp: In function 'int ask(std::vector<int>)':
carnival.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
     ~~~~~^~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 524 KB Output is correct
2 Correct 16 ms 504 KB Output is correct
3 Correct 10 ms 504 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 18 ms 504 KB Output is correct
6 Correct 11 ms 524 KB Output is correct
7 Correct 16 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 424 KB Output is correct
2 Correct 22 ms 424 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 19 ms 504 KB Output is correct
6 Correct 32 ms 504 KB Output is correct
7 Correct 11 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 456 KB Output is correct
2 Correct 17 ms 504 KB Output is correct
3 Correct 17 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 10 ms 444 KB Output is correct
6 Correct 15 ms 424 KB Output is correct
7 Correct 17 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 504 KB Output is correct
2 Correct 12 ms 440 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 27 ms 504 KB Output is correct
6 Correct 13 ms 424 KB Output is correct
7 Correct 19 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 504 KB Output is correct
2 Correct 14 ms 568 KB Output is correct
3 Correct 16 ms 376 KB Output is correct
4 Correct 13 ms 376 KB Output is correct
5 Correct 8 ms 316 KB Output is correct
6 Correct 9 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct