답안 #130295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130295 2019-07-14T17:05:28 Z PeppaPig 사육제 (CEOI14_carnival) C++14
80 / 100
29 ms 400 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 155;
 
int ask(vector<int> &v, int ret = 0) {
    printf("%d ", v.size());
    for(int i : v) printf("%d ", i);
    printf("\n"), fflush(stdout);
    scanf("%d", &ret);
    return ret;
}
 
int n, a[N];
 
int main() {
    scanf("%d", &n);
    vector<int> vec = {1};
    for(int i = 2; i <= n; i++) {
        vector<int> tmp = vec;
        tmp.emplace_back(i);
        if(ask(tmp) == tmp.size()) vec = tmp;
    }
    int cnt = n;
    for(int i = 1; i <= vec.size(); i++) a[vec[i-1]] = i, --cnt;
    for(int i = 1; i <= vec.size(); i++) {
        vector<int> now;
        for(int j = 1; j <= vec.size(); j++) if(j != i)
            now.emplace_back(vec[j-1]);
        while(cnt) {
            int l = 1, r = n;
            while(l < r) {
                int mid = (l + r) >> 1;
                vector<int> v = now;
                for(int j = 1; j <= mid; j++) if(!a[j] && j != vec[i - 1])
                    v.emplace_back(j);
                if(ask(v) == vec.size()) r = mid;
                else l = mid + 1;
            }
            vector<int> v = now;
            for(int j = 1; j <= r; j++) if(!a[j])
                v.emplace_back(j);
            if(ask(v) == vec.size()) a[r] = i, --cnt;
            else break;
        }
    }
    printf("0 ");
    for(int i = 1; i <= n; i++) printf("%d ", a[i]);
    printf("\n"), fflush(stdout);
 
    return 0;
}

Compilation message

carnival.cpp: In function 'int ask(std::vector<int>&, int)':
carnival.cpp:8: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: In function 'int main()':
carnival.cpp:23:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(ask(tmp) == tmp.size()) vec = tmp;
            ~~~~~~~~~^~~~~~~~~~~~~
carnival.cpp:26:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i <= vec.size(); i++) a[vec[i-1]] = i, --cnt;
                    ~~^~~~~~~~~~~~~
carnival.cpp:27:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i <= vec.size(); i++) {
                    ~~^~~~~~~~~~~~~
carnival.cpp:29:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 1; j <= vec.size(); j++) if(j != i)
                        ~~^~~~~~~~~~~~~
carnival.cpp:38:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(ask(v) == vec.size()) r = mid;
                    ~~~~~~~^~~~~~~~~~~~~
carnival.cpp:44:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(ask(v) == vec.size()) a[r] = i, --cnt;
                ~~~~~~~^~~~~~~~~~~~~
carnival.cpp: In function 'int ask(std::vector<int>&, int)':
carnival.cpp:11: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:18: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 22 ms 376 KB Output is correct
2 Correct 14 ms 312 KB Output is correct
3 Correct 24 ms 376 KB Output is correct
4 Correct 19 ms 248 KB Output is correct
5 Correct 18 ms 376 KB Output is correct
6 Correct 9 ms 376 KB Output is correct
7 Correct 20 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 252 KB Output is correct
2 Correct 24 ms 376 KB Output is correct
3 Correct 19 ms 248 KB Output is correct
4 Correct 23 ms 248 KB Output is correct
5 Correct 19 ms 248 KB Output is correct
6 Correct 18 ms 376 KB Output is correct
7 Correct 21 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3 ms 376 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 376 KB Output is correct
2 Correct 23 ms 376 KB Output is correct
3 Correct 23 ms 376 KB Output is correct
4 Correct 20 ms 252 KB Output is correct
5 Correct 20 ms 248 KB Output is correct
6 Correct 17 ms 376 KB Output is correct
7 Correct 23 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 248 KB Output is correct
2 Correct 24 ms 248 KB Output is correct
3 Correct 29 ms 248 KB Output is correct
4 Correct 20 ms 400 KB Output is correct
5 Correct 10 ms 320 KB Output is correct
6 Correct 11 ms 376 KB Output is correct
7 Correct 28 ms 376 KB Output is correct