Submission #764360

# Submission time Handle Problem Language Result Execution time Memory
764360 2023-06-23T11:07:22 Z Dan4Life Minerals (JOI19_minerals) C++17
Compilation error
0 ms 0 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define pb push_back
#define sz(a) (int)a.size()
int cur, pre;
bool Q(int i){ cur = Query(i); bool ok=(cur!=pre); pre=cur; return ok;}

void dnc(vi l, vi r, bool d){
    int n = sz(l); int m = max(1.0,n*0.4); if(n<1) return;
    if(n==1) return Answer(l[0],r[0]); 
    if(!d) m=n-m; vi w[2]; 
    for(int i : {0,1}) v[i].clear(), w[i].clear();
    for(int i = (d?0:m); i < (d?m:n); i++) Q(l[i]);
    for(int i = 0; i < n; i++) v[i>=m].pb(l[i]);
    random_shuffle(begin(r),end(r));
    for(int i : r){
      if(sz(w[0])==m) w[1].pb(i);
      else if(sz(w[1])==n-m) w[0].pb(i);
      else w[Q(i)].pb(i);
    }
    dnc(vi(begin(l),begin(l)+m),w[0],0); 
    dnc(vi(begin(l)+m,end(l)),v[1],w[1],1);
}

void Solve(int N) {
    vi w[2];
    for(int i = 1; i <= 2*N; i++) w[Q(i)].pb(i);
    dnc(w[0],w[1],0);
}

Compilation message

minerals.cpp: In function 'void dnc(vi, vi, bool)':
minerals.cpp:13:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   13 |     if(!d) m=n-m; vi w[2];
      |     ^~
minerals.cpp:13:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   13 |     if(!d) m=n-m; vi w[2];
      |                   ^~
minerals.cpp:14:24: error: 'v' was not declared in this scope
   14 |     for(int i : {0,1}) v[i].clear(), w[i].clear();
      |                        ^
minerals.cpp:16:32: error: 'v' was not declared in this scope
   16 |     for(int i = 0; i < n; i++) v[i>=m].pb(l[i]);
      |                                ^
minerals.cpp:24:31: error: 'v' was not declared in this scope
   24 |     dnc(vi(begin(l)+m,end(l)),v[1],w[1],1);
      |                               ^