Submission #48124

# Submission time Handle Problem Language Result Execution time Memory
48124 2018-05-10T06:17:53 Z jeff Carnival (CEOI14_carnival) C++14
0 / 100
4 ms 528 KB
#include <bits/stdc++.h>
using namespace std;

int id[150], rk[150], sr[150];
vector<int> tor;

int main() {
    int N, l, h, m, c, t = 0, i, j;
    scanf("%d", &N);
    for (i = 0; i < N; ++i) id[i] = i;
    for (i = 0; i < N; ++i) {
        printf("%d ", tor.size() + 1);
        for (j = 0; j < tor.size(); ++j) printf("%d ", tor[j] + 1);
        printf("%d\n", i + 1);
        fflush(stdout);
        scanf("%d", &c);
        if (c <= tor.size()) {
            l = 0;
            h = tor.size() - 1;
            while (l < h) {
                m = (l + h) / 2;
                printf("%d ", m + 2);
                for (j = l; j < m + 1; ++j) printf("%d ", tor[j] + 1);
                printf("%d\n", i + 1);
                fflush(stdout);
                scanf("%d", &c);
                (c <= m + 1 ? h : l) = m + (c > m + 1);
            }
            id[i] = tor[(l + h) / 2];
        } else tor.push_back(i);
    }
    printf("0 ");
    for (i = 0; i < N; ++i) {
        if (i == id[i]) sr[i] = ++t;
        printf("%d%c", sr[id[i]], i < N - 1 ? ' ' : '\n');
    }
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:12:37: 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 ", tor.size() + 1);
                       ~~~~~~~~~~~~~~^
carnival.cpp:13:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j = 0; j < tor.size(); ++j) printf("%d ", tor[j] + 1);
                     ~~^~~~~~~~~~~~
carnival.cpp:17:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (c <= tor.size()) {
             ~~^~~~~~~~~~~~~
carnival.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
carnival.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &c);
         ~~~~~^~~~~~~~~~
carnival.cpp:26:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf("%d", &c);
                 ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 248 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 336 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Execution timed out 2 ms 528 KB Time limit exceeded (wall clock)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 528 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 528 KB Output is correct
2 Execution timed out 2 ms 528 KB Time limit exceeded (wall clock)
3 Halted 0 ms 0 KB -