답안 #996186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996186 2024-06-10T08:35:32 Z vjudge1 사육제 (CEOI14_carnival) C++17
100 / 100
8 ms 716 KB
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(ll  i=(a);i<=(b);i++)
#define Ford(i,a,b) for(ll  i=(a);i>=(b);i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
//#define endl "\n"
using namespace std;
int Dx[] = {0, 1, 0, -1, -1, -1, 1, 1};
int Dy[] = {-1, 0, 1, 0, 1, -1, 1, -1};
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
const ll inf = 1000000000000000000;
const ll N = 100000;
const int block_size = 300;
const ll MOD =  998244353; /* 998244353 */
const int LG = 18;
const int K = 20;
const int M = 1000000;
ll nph(ll k, ll x) { return ((x >> k) & 1); }

void Solve() {
    ll n,x,y; cin>>n; ll pre[n+3]; pre[0] = 0;
    vector<ll> justask;
    vector<vector<ll>> ans; ans.pb({});
    For(i, 1, n) {
        cout << i << " ";
        for(auto x : justask) cout << x << " ";
        cout << i << endl;
        justask.pb(i);
        cin>>x; pre[i] = x;
        if(pre[i] != pre[i-1]) ans.pb({i});
        else {
            ll l = 1, r = ans.size() - 1, pos;
            while(l <= r) {
                ll md = l + r >> 1;
                vector<ll> v;
                For(j, 1, md) {
                    for(auto x : ans[j]) v.pb(x);
                }
                cout << v.size() + 1 << " ";
                for(auto x : v) cout << x << " ";
                cout << i << endl;
                cin>>x;
                if(x == md) {
                    pos = md; r = md - 1;
                }
                else l = md + 1;
            }
            ans[pos].pb(i);
        }
    }
    ll idk[n+3], cnt = 1;
    for(ll i = 1; i < ans.size(); i++) {
        for(auto y : ans[i]) {
            idk[y] = cnt;
        }
        cnt++;
    }
    cout << 0 << " ";
    For(i, 1, n) cout << idk[i] << " ";
}
int main() {
    // freopen("Bai2.inp", "r", stdin);
    // freopen("Bai2.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    	Solve();
}

Compilation message

carnival.cpp: In function 'void Solve()':
carnival.cpp:40:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |                 ll md = l + r >> 1;
      |                         ~~^~~
carnival.cpp:58:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(ll i = 1; i < ans.size(); i++) {
      |                   ~~^~~~~~~~~~~~
carnival.cpp:27:12: warning: unused variable 'y' [-Wunused-variable]
   27 |     ll n,x,y; cin>>n; ll pre[n+3]; pre[0] = 0;
      |            ^
carnival.cpp:54:20: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |             ans[pos].pb(i);
      |                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 464 KB Output is correct
2 Correct 8 ms 600 KB Output is correct
3 Correct 6 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 5 ms 600 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 5 ms 708 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 5 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 5 ms 456 KB Output is correct
3 Correct 8 ms 460 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 5 ms 460 KB Output is correct
6 Correct 7 ms 460 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 6 ms 600 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 8 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 7 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 6 ms 460 KB Output is correct
3 Correct 6 ms 716 KB Output is correct
4 Correct 6 ms 464 KB Output is correct
5 Correct 4 ms 464 KB Output is correct
6 Correct 3 ms 460 KB Output is correct
7 Correct 2 ms 344 KB Output is correct