답안 #68287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68287 2018-08-16T11:25:30 Z polyfish 사육제 (CEOI14_carnival) C++14
0 / 100
28 ms 548 KB
//I love armpit fetish

#include <bits/stdc++.h>
using namespace std;

#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAX_N = 152;

int n, nColor, c[MAX_N];

int ask(int u, int l, int r) {
    printf("%d\n", r-l+2);
    fflush(stdout);
    printf("%d ", u);
    fflush(stdout);
    fflush(stdout);
    for (int i=l; i<=r; ++i) {
        printf("%d ", i);
        fflush(stdout);
    }
    printf("\n");
    fflush(stdout);
    int res;
    cin >> res;
    return res;
}

void solve(int u) {
    int l = u+1, r = n;
    while (l<r) {
        int mid = (l + r) / 2;
        if (ask(u, l, mid)<mid-l+2)
            r = mid;
        else
            l = mid + 1;
    }
    if (ask(u, r, r)==1)
        c[u] = -r;
    else
        c[u] = ++nColor;
}

void find_result() {
    c[n] = ++nColor;
    for (int i=n; i>=1; --i)
        if (c[i]<0)
            c[i] = c[-c[i]];
    printf("0\n");
    fflush(stdout);
    for (int i=1; i<=n; ++i) {
        printf("%d ", c[i]);
        fflush(stdout);
    }
    fflush(stdout);
}

int main() {
	//#define OFFLINE_JUDGE doraemon
	#ifdef OFFLINE_JUDGE
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	//ios::sync_with_stdio(0); cin.tie(0);
    scanf("%d", &n);
    for (int i=1; i<n; ++i)
        solve(i);
    find_result();
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:69:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 248 KB Integer 15 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 308 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 392 KB Output is correct
2 Incorrect 27 ms 392 KB Integer 9 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 392 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 548 KB Integer 5 violates the range [1, 2]
2 Halted 0 ms 0 KB -