답안 #164470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164470 2019-11-21T02:18:20 Z mhy908 사육제 (CEOI14_carnival) C++14
100 / 100
27 ms 376 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL llinf=9000000000000000000;
const int inf=2000000000;
int query(int a, int b){
    printf("%d ", b-a+1);
    for(int i=a; i<=b; i++)printf("%d ", i);
    fflush(stdout);
    int ret;
    scanf("%d", &ret);
    return ret;
}
int n, col[160], r=1;
int sum[160];
int main()
{
    scanf("%d", &n);
    col[1]=sum[1]=1;
    for(int i=2; i<=n; i++){
        sum[i]=query(1, i);
        if(sum[i-1]+1==sum[i]){
            col[i]=++r;
            continue;
        }
        else{
            int s=1, e=i-1;
            while(s<e){
                int mid=(s+e+1)/2;
                if(query(mid, i)==query(mid, i-1)+1)e=mid-1;
                else s=mid;
            }
            col[i]=col[s];
        }
    }
    printf("0 ");
    for(int i=1; i<=n; i++)printf("%d ", col[i]);
}

Compilation message

carnival.cpp: In function 'int query(int, int)':
carnival.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &ret);
     ~~~~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:24: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 15 ms 248 KB Output is correct
2 Correct 22 ms 248 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 26 ms 248 KB Output is correct
6 Correct 21 ms 340 KB Output is correct
7 Correct 21 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 248 KB Output is correct
2 Correct 25 ms 376 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 24 ms 248 KB Output is correct
6 Correct 17 ms 248 KB Output is correct
7 Correct 26 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 248 KB Output is correct
2 Correct 27 ms 248 KB Output is correct
3 Correct 23 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 22 ms 248 KB Output is correct
6 Correct 22 ms 376 KB Output is correct
7 Correct 12 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 376 KB Output is correct
2 Correct 24 ms 248 KB Output is correct
3 Correct 10 ms 252 KB Output is correct
4 Correct 6 ms 248 KB Output is correct
5 Correct 21 ms 248 KB Output is correct
6 Correct 16 ms 376 KB Output is correct
7 Correct 13 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 376 KB Output is correct
2 Correct 24 ms 376 KB Output is correct
3 Correct 10 ms 248 KB Output is correct
4 Correct 14 ms 376 KB Output is correct
5 Correct 13 ms 376 KB Output is correct
6 Correct 12 ms 248 KB Output is correct
7 Correct 5 ms 248 KB Output is correct