답안 #419579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
419579 2021-06-07T09:48:45 Z freshmintt 사육제 (CEOI14_carnival) C++14
100 / 100
14 ms 436 KB
#include<bits/stdc++.h>
#define MAXN 155 //change. SET A SPACIOUS MAXN WHEN TESTING SO YOU DONT MESS UP WITH GARBAGE VALS OR SHIT
using namespace std;
typedef pair<long long,long long> pi;
typedef long long ll;
typedef long double ld;
ll N;
 
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
 
 
int main() { 
  // freopen("in", "r", stdin); // comment out
  FIO;
  cin >> N;

  ll assigns[MAXN]; fill(assigns, assigns+MAXN, 1);

  bool unique[MAXN]; fill(unique, unique+MAXN, false);
  
  vector<ll> ref;
  ref.push_back(1); unique[1] = true; assigns[1] = 1;

  ll res;

  ll prev = 1;
  for (ll i = 2; i <= N; i++) {
    cout << i << " ";
    for (ll j = 1; j <= i; j++) {
      cout << j << " ";
    }
    cout << endl; // MUST CALL AN ENDL BEFORE DOING FLUSH!
    fflush(stdout);
    cin >> res;
    if (res > prev) {
      ref.push_back(i);
      unique[i] = true;
    //   // cout << "assigning " << i << endl;
      assigns[i] = i;
    }
    prev = res;
      
  }
  // // cout << endl;
  // // for (auto item : ref) {
  // //   cout << item << endl;
  // // }


  for (ll i = 2; i <= N; i ++) {
    if (unique[i]) continue;
    ll a = 0; ll b = ref.size(); ll mid;
    while (a != b) {
      mid = (a + b) / 2;
      
      // test party a->mid and i
      // cout << "building output: " << endl; 
      cout << mid-a+2 << " ";
      for (ll x = a; x <= mid; x++) {
        cout << ref[x] << " ";
      }
      cout << i << endl;

      fflush(stdout);
      cin >> res;

      if (res == mid-a+1) {
        // cout << "testing lower half " << endl;
        b = mid;
      }
      else {
        // cout << "testing upper half" << endl;
        a = mid + 1;
      }
       
    }
    // cout << i << " belongs to: " << ref[a] << endl;
    assigns[i] = ref[a];
  }
  // cout <<"ans: ";
  // for (ll i = 1; i <= N; i++) {
  //   cout << assigns[i] << " ";
  // }
  // cout << endl;

  cout << "0 ";
  map<ll,ll> x;
  ll count = 0;
  for (ll i = 1; i <= N; i++) {
    if (x.find(assigns[i]) == x.end()) {
      x[assigns[i]] = ++count;
      // cout << "assigining " << x[assigns[i]] << " to " << assigns[i] << endl;
    }
    cout << x[assigns[i]] << " "; 
  }

  cout << endl;
  fflush(stdout);


 
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 200 KB Output is correct
2 Correct 9 ms 304 KB Output is correct
3 Correct 5 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 6 ms 200 KB Output is correct
6 Correct 4 ms 200 KB Output is correct
7 Correct 8 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 200 KB Output is correct
2 Correct 8 ms 312 KB Output is correct
3 Correct 4 ms 200 KB Output is correct
4 Correct 5 ms 200 KB Output is correct
5 Correct 10 ms 200 KB Output is correct
6 Correct 9 ms 200 KB Output is correct
7 Correct 10 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 200 KB Output is correct
2 Correct 6 ms 200 KB Output is correct
3 Correct 9 ms 200 KB Output is correct
4 Correct 3 ms 436 KB Output is correct
5 Correct 9 ms 200 KB Output is correct
6 Correct 10 ms 200 KB Output is correct
7 Correct 8 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 200 KB Output is correct
2 Correct 7 ms 200 KB Output is correct
3 Correct 6 ms 200 KB Output is correct
4 Correct 3 ms 316 KB Output is correct
5 Correct 7 ms 200 KB Output is correct
6 Correct 10 ms 296 KB Output is correct
7 Correct 14 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 200 KB Output is correct
2 Correct 10 ms 200 KB Output is correct
3 Correct 6 ms 312 KB Output is correct
4 Correct 8 ms 200 KB Output is correct
5 Correct 9 ms 316 KB Output is correct
6 Correct 7 ms 200 KB Output is correct
7 Correct 3 ms 312 KB Output is correct