답안 #740623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
740623 2023-05-12T21:37:12 Z jampm 사육제 (CEOI14_carnival) C++17
100 / 100
10 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
int const Mxn = 15e1 + 1;
#define sz(a) (int)a.size()

vector<int> Heads, Head;

bool query(int l, int r, int k) {
  cout << r - l + 1 << " " << k << " ";
  for (int i = l; i < r; i++) cout << Heads[i] << " ";
  cout << endl;
  int x; cin >> x;
  return (x == r - l);
}

void find(int L, int R, int k) {
  if (L + 1 == R) {
    Head[k] = Heads[L]; return;
  }
  int Mid = (L + R)>>1;
  if (query(L, Mid, k)) find(L, Mid, k);
  else find(Mid, R, k);
}

int main() {
  int n; cin >> n;
  Heads.push_back(1);
  Head.resize(n + 1); iota(Head.begin(), Head.end(), 0);
  for (int i = 2; i <= n; i++) {
    if (query(0, sz(Heads), i)) find(0, sz(Heads), i);
    else Heads.push_back(i);
  }
  map<int, int> cc; int cnt = 1;
  for (int i = 1; i <= n; i++) cc[Head[i]]++;
  for (auto &[x, y] : cc) y = cnt++;
  cout << 0 << " ";
  for (int i = 1; i <= n; i++) {
    cout << cc[Head[i]] << " ";
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 8 ms 296 KB Output is correct
3 Correct 6 ms 336 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 5 ms 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 3 ms 300 KB Output is correct
5 Correct 6 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 2 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 9 ms 300 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 5 ms 300 KB Output is correct
6 Correct 5 ms 300 KB Output is correct
7 Correct 6 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 4 ms 300 KB Output is correct
4 Correct 4 ms 296 KB Output is correct
5 Correct 7 ms 296 KB Output is correct
6 Correct 7 ms 296 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 6 ms 296 KB Output is correct
5 Correct 6 ms 300 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 3 ms 208 KB Output is correct