답안 #533288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533288 2022-03-05T08:51:47 Z devariaota 사육제 (CEOI14_carnival) C++17
100 / 100
12 ms 280 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n, mx = 1;
int arr[155];
int ans[155];

int ask(int mid, int x) {
  cout << mid + 1 << " ";
  for(int i = 1; i <= mid; i++) {
    cout << i << " ";
  }
  cout << x << "\n";
  cout.flush();
  int ret;
  cin >> ret;
  return ret;
}

int main() {
  cin >> n;
  arr[1] = 1;
  ans[1] = 1;
  for(int i = 2; i <= n; i++) {
    cout << i << " ";
    for(int j = 1; j <= i; j++) {
      cout << j;
      if (j < i) {
        cout << " ";
      }
    }
    cout << '\n';
    cout.flush();
    cin >> arr[i];
    if (arr[i] > mx) {
      mx = arr[i];
      ans[i] = arr[i];
    }
  }
  
  /*
  for(int i = 1; i <= n; i++) {
    cout << ans[i] << "-";
  }
  cout << endl;
  */
  for(int i = 2; i <= n; i++) {
    if (ans[i] == 0) {
      int l = 1, r = i - 1, ret = 0;
      while(l <= r) {
        int mid = (l + r) / 2;
        if (ask(mid, i) == arr[mid]) {
          ret = mid;
          r = mid - 1;
        }
        else {
          l = mid + 1;
        }
      }
      ans[i] = arr[ret];
      /*
      for(int i = 1; i <= n; i++) {
        cout << ans[i] << "-";
      }
      cout << endl;
      */
    }
  }
  cout << 0 << " ";
  for(int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
  cout.flush();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 200 KB Output is correct
2 Correct 10 ms 200 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 9 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 200 KB Output is correct
2 Correct 10 ms 280 KB Output is correct
3 Correct 5 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 9 ms 200 KB Output is correct
6 Correct 12 ms 200 KB Output is correct
7 Correct 10 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 200 KB Output is correct
2 Correct 9 ms 200 KB Output is correct
3 Correct 8 ms 200 KB Output is correct
4 Correct 3 ms 200 KB Output is correct
5 Correct 9 ms 200 KB Output is correct
6 Correct 9 ms 200 KB Output is correct
7 Correct 11 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 200 KB Output is correct
2 Correct 11 ms 200 KB Output is correct
3 Correct 6 ms 200 KB Output is correct
4 Correct 3 ms 200 KB Output is correct
5 Correct 9 ms 200 KB Output is correct
6 Correct 7 ms 200 KB Output is correct
7 Correct 8 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 200 KB Output is correct
2 Correct 10 ms 200 KB Output is correct
3 Correct 7 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 8 ms 200 KB Output is correct
6 Correct 5 ms 200 KB Output is correct
7 Correct 4 ms 200 KB Output is correct