답안 #346625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
346625 2021-01-10T12:51:30 Z iliccmarko 사육제 (CEOI14_carnival) C++14
100 / 100
16 ms 492 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
const int N = 155;
int a[N];
int n;



int main()
{
    ios
    cin>>n;
    a[1] = 1;
    int cnt = 1;
    for(int i = 2;i<=n;i++)
    {
        cout<<i<<" ";
        for(int j = 1;j<=i;j++)
        {
            cout<<j<<" ";
        }
        cout<<flush;
        int num;
        cin>>num;
        if(num!=cnt)
        {
            a[i] = ++cnt;
            continue;
        }
        int l = 1;
        int r = i-1;
        int ans;
        while(l<=r)
        {
            int mid = (l+r)/2;
            set<int> s;
            int w = i - mid + 1;
            cout<<w<<" ";
            for(int q = mid;q<=i;q++) cout<<q<<" ";
            cout<<flush;
            int f;
            cin>>f;
            for(int q = mid;q<i;q++) s.insert(a[q]);
            if(f!=len(s))
            {
                r = mid - 1;
            }
            else
            {
                ans = mid;
                l = mid + 1;
            }
        }
        a[i] = a[ans];
    }
    
    cout<<0<<" ";
    for(int i = 1;i<=n;i++) cout<<a[i]<<" ";
    
    
    
    
    
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:66:21: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |         a[i] = a[ans];
      |                ~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 364 KB Output is correct
2 Correct 10 ms 364 KB Output is correct
3 Correct 6 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 11 ms 364 KB Output is correct
6 Correct 10 ms 364 KB Output is correct
7 Correct 10 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 364 KB Output is correct
2 Correct 13 ms 364 KB Output is correct
3 Correct 5 ms 364 KB Output is correct
4 Correct 6 ms 364 KB Output is correct
5 Correct 14 ms 364 KB Output is correct
6 Correct 14 ms 364 KB Output is correct
7 Correct 14 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 364 KB Output is correct
2 Correct 11 ms 364 KB Output is correct
3 Correct 11 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 8 ms 364 KB Output is correct
6 Correct 11 ms 364 KB Output is correct
7 Correct 7 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 384 KB Output is correct
2 Correct 11 ms 364 KB Output is correct
3 Correct 6 ms 364 KB Output is correct
4 Correct 4 ms 392 KB Output is correct
5 Correct 9 ms 364 KB Output is correct
6 Correct 7 ms 364 KB Output is correct
7 Correct 12 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 364 KB Output is correct
2 Correct 11 ms 364 KB Output is correct
3 Correct 10 ms 364 KB Output is correct
4 Correct 9 ms 364 KB Output is correct
5 Correct 9 ms 384 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 5 ms 364 KB Output is correct