제출 #1293130

#제출 시각아이디문제언어결과실행 시간메모리
1293130yf_yusuf코알라 (APIO17_koala)C++20
컴파일 에러
0 ms0 KiB
#include "koala.h" int B[100], R[100]; int minValue(int N, int W) { B[0] = 1; playRound(B, R); int j; for(int i=0;i<N;i++){ if(!R[i]) j = i; } return j; } int maxValue(int N, int W) { vll v; for(int i=0;i<N;i++)v.pb(i); while(v.size() > 1){ ll x = (W / v.size()); fill(B, B+N, 0); for(auto i : v)B[i] = x; playRound(B, R); v.clear(); for(int i=0;i<N;i++) if(R[i] > x)v.pb(i); } return v[0]; } int i=0, j=1; int greaterValue(int N, int W) { ll l = 1, r = 9; fill(B, B+N, 0); while(l!=r){ ll m=(l+r)>>1; B[i] = B[j] = m; playRound(B, R); if (R[i] > m && R[j] > m) l = m + 1; else if (R[i] <= m && R[j] <= m) r = m - 1; else return (R[i] < R[j]); } B[i] = B[j] = l; playRound(B, R); fill(B, B+N, 0); return (R[i] < R[j]); } bool better(int i, int j, int N, int W){ fill(B, B+N, 0); B[i] = B[j] = W / 2; playRound(B, R); return (R[j] > W/2); } bool BETTER(int I, int J, int N, int W){ i=I; j=J; return greaterValue(N, W); } vll dac(vll v, int N, int W, bool ww = 0){ if(v.size() == 1)return v; vll a, b; int md = (v.size() + 1)/2; for(int i=0 ;i<md ;i++)a.pb(v[i]); for(int i=md;i<v.size();i++)b.pb(v[i]); a = dac(a, N, W, ww); b = dac(b, N, W, ww); vll c; int l=0,r=0; while(l < a.size() && r < b.size()){ if((ww ? BETTER(a[l], b[r], N, W) : better(a[l], b[r], N, W))) c.pb(a[l++]); else c.pb(b[r++]); } while(l < a.size())c.pb(a[l++]); while(r < b.size())c.pb(b[r++]); return c; } void split(vll v,ll N,ll W, int *P, ll l,ll r){ // for(auto i : v)cout<<i<<" ";cout<<l<<" "<<r<<" NW\n"; if(v.size() == 1)P[v[0]] = l; else{ ll w = min((ll)(sqrt(2 * l)), W / (r-l+1)); fill(B, B+N, 0); for(auto i : v)B[i] = w; playRound(B, R); vll ls, gr; for(auto i : v){ (R[i] > w ? gr : ls).pb(i); // cout<<R[i]<<" "; } // cout<<"r\n"; split(ls, N, W, P, l, l + ls.size() - 1); split(gr, N, W, P, r - gr.size() + 1, r); } } void allValues(int N, int W, int *P) { if(N+N == W){ vll v; for(int i=0;i<N;i++)v.pb(i); v = dac(v, N, W); for(int i=0;i<N;i++)P[v[i]] = i+1; } else{ vll v; for(int i=0;i<N;i++)v.pb(i); split(v, N, W, P, 1, N); } }

컴파일 시 표준 에러 (stderr) 메시지

koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:16:9: error: 'vll' was not declared in this scope
   16 |         vll v;
      |         ^~~
koala.cpp:17:29: error: 'v' was not declared in this scope
   17 |         for(int i=0;i<N;i++)v.pb(i);
      |                             ^
koala.cpp:18:15: error: 'v' was not declared in this scope
   18 |         while(v.size() > 1){
      |               ^
koala.cpp:19:17: error: 'll' was not declared in this scope
   19 |                 ll x = (W / v.size());
      |                 ^~
koala.cpp:20:17: error: 'fill' was not declared in this scope
   20 |                 fill(B, B+N, 0);
      |                 ^~~~
koala.cpp:21:39: error: 'x' was not declared in this scope
   21 |                 for(auto i : v)B[i] = x;
      |                                       ^
koala.cpp:25:35: error: 'x' was not declared in this scope
   25 |                         if(R[i] > x)v.pb(i);
      |                                   ^
koala.cpp:27:16: error: 'v' was not declared in this scope
   27 |         return v[0];
      |                ^
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:31:9: error: 'll' was not declared in this scope
   31 |         ll l = 1, r = 9;
      |         ^~
koala.cpp:32:9: error: 'fill' was not declared in this scope
   32 |         fill(B, B+N, 0);
      |         ^~~~
koala.cpp:33:15: error: 'l' was not declared in this scope
   33 |         while(l!=r){
      |               ^
koala.cpp:33:18: error: 'r' was not declared in this scope
   33 |         while(l!=r){
      |                  ^
koala.cpp:34:19: error: expected ';' before 'm'
   34 |                 ll m=(l+r)>>1;
      |                   ^~
      |                   ;
koala.cpp:35:31: error: 'm' was not declared in this scope
   35 |                 B[i] = B[j] = m;
      |                               ^
koala.cpp:41:23: error: 'l' was not declared in this scope
   41 |         B[i] = B[j] = l;
      |                       ^
koala.cpp: In function 'bool better(int, int, int, int)':
koala.cpp:47:9: error: 'fill' was not declared in this scope
   47 |         fill(B, B+N, 0);
      |         ^~~~
koala.cpp: At global scope:
koala.cpp:56:1: error: 'vll' does not name a type
   56 | vll dac(vll v, int N, int W, bool ww = 0){
      | ^~~
koala.cpp:76:6: error: variable or field 'split' declared void
   76 | void split(vll v,ll N,ll W, int *P, ll l,ll r){
      |      ^~~~~
koala.cpp:76:12: error: 'vll' was not declared in this scope
   76 | void split(vll v,ll N,ll W, int *P, ll l,ll r){
      |            ^~~
koala.cpp:76:18: error: 'll' was not declared in this scope
   76 | void split(vll v,ll N,ll W, int *P, ll l,ll r){
      |                  ^~
koala.cpp:76:23: error: 'll' was not declared in this scope
   76 | void split(vll v,ll N,ll W, int *P, ll l,ll r){
      |                       ^~
koala.cpp:76:29: error: expected primary-expression before 'int'
   76 | void split(vll v,ll N,ll W, int *P, ll l,ll r){
      |                             ^~~
koala.cpp:76:37: error: 'll' was not declared in this scope
   76 | void split(vll v,ll N,ll W, int *P, ll l,ll r){
      |                                     ^~
koala.cpp:76:42: error: 'll' was not declared in this scope
   76 | void split(vll v,ll N,ll W, int *P, ll l,ll r){
      |                                          ^~
koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:96:17: error: 'vll' was not declared in this scope
   96 |                 vll v;
      |                 ^~~
koala.cpp:97:37: error: 'v' was not declared in this scope
   97 |                 for(int i=0;i<N;i++)v.pb(i);
      |                                     ^
koala.cpp:98:17: error: 'v' was not declared in this scope
   98 |                 v = dac(v, N, W);
      |                 ^
koala.cpp:98:21: error: 'dac' was not declared in this scope
   98 |                 v = dac(v, N, W);
      |                     ^~~
koala.cpp:101:17: error: 'vll' was not declared in this scope
  101 |                 vll v;
      |                 ^~~
koala.cpp:102:37: error: 'v' was not declared in this scope
  102 |                 for(int i=0;i<N;i++)v.pb(i);
      |                                     ^
koala.cpp:103:23: error: 'v' was not declared in this scope
  103 |                 split(v, N, W, P, 1, N);
      |                       ^
koala.cpp:103:17: error: 'split' was not declared in this scope
  103 |                 split(v, N, W, P, 1, N);
      |                 ^~~~~