답안 #95412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95412 2019-01-31T19:01:12 Z popovicirobert 사육제 (CEOI14_carnival) C++14
100 / 100
12 ms 396 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;

const int MAXN = 150;

int arr[MAXN + 1];

inline int ask(int l, int r) {
    cout << r - l + 1 << " ";
    for(int i = l; i <= r; i++) {
        cout << i << " ";
    }
    cout << "\n";
    int ans;
    cin >> ans;
    return ans;
}

bool vis[MAXN + 1];

inline int get(int l, int r) {
    for(int i = l; i <= r; i++) {
        vis[arr[i]] = 0;
    }
    int ans = 0;
    for(int i = l; i <= r; i++) {
        ans += 1 - vis[arr[i]];
        vis[arr[i]] = 1;
    }
    return ans;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    //cin.tie(0), cout.tie(0);
    cin >> n;
    int cnt = 0;
    int id = 0;
    for(i = 1; i <= n; i++) {
        int cur = ask(1, i);
        if(cur > cnt) {
            arr[i] = ++id;
        }
        else {
            int res = 0;
            for(int step = 1 << 8; step; step >>= 1) {
                if(res + step < i && ask(res + step, i) == get(res + step, i - 1)) {
                    res += step;
                }
            }
            arr[i] = arr[res];
        }
        cnt = cur;
    }
    cout << 0 << " ";
    for(i = 1; i <= n; i++) {
        cout << arr[i] << " ";
    }
    cout << "\n";
    //cin.close();
    //cout.close();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 292 KB Output is correct
2 Correct 9 ms 248 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 4 ms 380 KB Output is correct
5 Correct 9 ms 248 KB Output is correct
6 Correct 4 ms 248 KB Output is correct
7 Correct 11 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 248 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 9 ms 376 KB Output is correct
6 Correct 8 ms 248 KB Output is correct
7 Correct 11 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 11 ms 248 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 8 ms 376 KB Output is correct
6 Correct 7 ms 380 KB Output is correct
7 Correct 12 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 248 KB Output is correct
2 Correct 11 ms 248 KB Output is correct
3 Correct 6 ms 248 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 9 ms 376 KB Output is correct
6 Correct 7 ms 248 KB Output is correct
7 Correct 6 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 376 KB Output is correct
2 Correct 11 ms 248 KB Output is correct
3 Correct 5 ms 396 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 4 ms 248 KB Output is correct
6 Correct 4 ms 248 KB Output is correct
7 Correct 5 ms 248 KB Output is correct