답안 #740344

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
740344 2023-05-12T11:07:31 Z Unforgettablepl 사육제 (CEOI14_carnival) C++17
100 / 100
9 ms 316 KB
/*
ID: samikgo1
TASK:
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<ll,ll> pll;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define f first
#define s second
//#define x first
//#define y second
const int INF = INT32_MAX;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("haybales.in","r",stdin);
//    freopen("haybales.out","w",stdout);
    int n;
    cin >> n;
    vector<int> unique = {1};
    vector<int> ans(n+1);
    ans[1] = 1;
    for (int i = 2; i <= n; i++) {
        cout << unique.size()+1;
        for(int&j:unique)cout << ' ' << j;
        cout << ' ' << i << endl;
        int a;
        cin >> a;
        if(a==unique.size()+1){
            unique.emplace_back(i);
            ans[i] = unique.size();
        } else {
            // Now binary search
            int l = 0;
            int r = unique.size()-1;
            while(l<r){
                int mid = (l+r)>>1;
                cout << mid-l+2;
                for (int j = l; j <= mid; j++) {
                    cout << ' ' << unique[j];
                }
                cout << ' ' << i << endl;
                cin >> a;
                if(a==mid-l+2){l=mid+1;}
                else{r = mid;}
            }
            ans[i] = ans[unique[l]];
        }
    }
    cout << '0';
    for(int i=1;i<=n;i++)cout<<' '<<ans[i];
    cout << endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:34:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if(a==unique.size()+1){
      |            ~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 3 ms 220 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 4 ms 316 KB Output is correct