답안 #532295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532295 2022-03-02T16:54:40 Z kebine 사육제 (CEOI14_carnival) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
  cin.tie(0) -> ios_base::sync_with_stdio(0);

  int n;
  cin >> n;
  vector<int> a(n + 1);
  auto ask = [&](int l, int r) -> int {
    cout << r - l + 1 << " ";
    for(int i=l;i<=r;i++)
    {
      cout << i << " ";
    }
    cout << endl;
    int ret;
    cin >> ret;
    return ret;
  };
    a[1] = 1;
  for(int i=2,cur=1;i<=n;i++)
  {
        if(ask(1, i) != ask(1, i-1))
        {
            a[i] = ++cur;
            continue;
        }
    int l = 1, r = i - 1;
    while(l < r)
    {
      int mid = (l + r + 1) / 2;
      if(ask(mid, i-1) == ask(mid, i))
      {
        l = mid;
      }
      else
      {
        r = mid - 1;
      }
    }
        a[i] = ans[l];
  }  
    cout << "0 ";
    for(int i=1;i<=n;i++)
    {
      cout << a[i] << " ";
    }
    cout << endl;
  
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:42:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |         a[i] = ans[l];
      |                ^~~
      |                abs