답안 #620198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
620198 2022-08-03T03:23:39 Z czhang2718 Super Dango Maker (JOI22_dango3) C++17
컴파일 오류
0 ms 0 KB
#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=a; i<=b; i++)

int qry(vector<int> v){
  cout << "? ";
  for(int x:v) cout << x << " ";
  cout << endl;
int ret; cin >> ret;
return ret;
}

void ans(vector<int> v){
  cout << "! ";
  for(int x:v) cout << x << " ";
    cout << endl;
}
vector<vector<int>> dango;
int kill[100000];
int it;

void solve(int l, int r, int li, int ri){
  if(r<l) return;
  int m=(l+r)/2;
  int p=li-1;
  auto ck=[&](int p)->bool{
    // cout << "try " << p << endl;
    vector<int> qu;
    for(int i=0; i<=p; i++){
      // cout << "kill[" << i << "] " << kill[i] << "\n";
      if(kill[i] && kill[i]<it) continue;
      qu.push_back(i);
    }
    for(int i=0; i<m; i++){
      for(int x:dango[i]) qu.push_back(x);
    }
    return Query(qu)<m;
  };
  for(int k=31-__builtin_clz(ri-li+1); k>=0; k--){
    if(p+(1<<k)<ri && ck(p+(1<<k))) p+=(1<<k);
  }
  p++;
  kill[p]=it;
  // cout << "kill " << p << " = " << it << endl;
  solve(l, m-1, li, p-1);
  solve(m+1, r, p, ri);
}

void Solve(int n, int m) {
  dango.resize(m);

  for(it=1; it<=n; it++){
    solve(1, m, 0, n*m-1);
    int j=0;
    for(int i=0; i<n*m; i++){
      if(kill[i]==it){
        dango[j++].push_back(i+1);
      }
    }
  }

  for(int i=0; i<m; i++) Answer(dango[i]);
}

// int main(){
//   Solve(3, 2);
// }

Compilation message

dango3.cpp:21:16: error: 'int kill [100000]' redeclared as different kind of entity
   21 | int kill[100000];
      |                ^
In file included from /usr/include/c++/10/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:43,
                 from dango3.cpp:2:
/usr/include/signal.h:112:12: note: previous declaration 'int kill(__pid_t, int)'
  112 | extern int kill (__pid_t __pid, int __sig) __THROW;
      |            ^~~~
dango3.cpp: In lambda function:
dango3.cpp:33:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |       if(kill[i] && kill[i]<it) continue;
      |                ^
dango3.cpp:33:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |       if(kill[i] && kill[i]<it) continue;
      |                           ^
dango3.cpp:33:28: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   33 |       if(kill[i] && kill[i]<it) continue;
      |                     ~~~~~~~^~~
dango3.cpp: In function 'void solve(int, int, int, int)':
dango3.cpp:45:9: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |   kill[p]=it;
      |         ^
dango3.cpp:45:10: error: assignment of read-only location '*(kill + ((sizetype)p))'
   45 |   kill[p]=it;
      |   ~~~~~~~^~~
dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:58:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   58 |       if(kill[i]==it){
      |                ^
dango3.cpp:58:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   58 |       if(kill[i]==it){
      |          ~~~~~~~^~~~