제출 #1032273

#제출 시각아이디문제언어결과실행 시간메모리
1032273Maite_MoraleA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

#include "books.h"

using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
//     books.h books_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ books_sample.cpp sample_grader.cpp
// in this folder.
//


void solve(int n, int k, long long A, int S) {
    vi v(n+5,0),knowed,r={};ll s=0;
    for(int i=1;i<=k;i++){
        r.push_back(i);
        v[i]=skim(i);s+=v[i];
        if(s>2*A){
            impossible();
            return;
        }
    }
    ll last=n+1;
    for(int i=k;i>0;i--){
        s-=v[i];
        ll p=i,f=last;
        while(abs(p-f)!=1){
            ll md=(p+f)/2;
            if(v[md]==0)v[md]=skim(md);
            if(s+v[md]<A)p=md;
            else if(s+v[md]>2*A)f=md;
                 else{
                    r[i-1]=md;
                    answer(r);
                    return;
                 }
        }//for(auto x : r)cout<<x<<" ";cout<<"\n";
        r[i-1]=p;
        s+=v[p];
        last=p;
    }
impossible();
}

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

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:18:5: error: 'vi' was not declared in this scope
   18 |     vi v(n+5,0),knowed,r={};ll s=0;
      |     ^~
books.cpp:18:29: error: 'll' was not declared in this scope
   18 |     vi v(n+5,0),knowed,r={};ll s=0;
      |                             ^~
books.cpp:20:9: error: 'r' was not declared in this scope
   20 |         r.push_back(i);
      |         ^
books.cpp:21:9: error: 'v' was not declared in this scope
   21 |         v[i]=skim(i);s+=v[i];
      |         ^
books.cpp:21:22: error: 's' was not declared in this scope
   21 |         v[i]=skim(i);s+=v[i];
      |                      ^
books.cpp:27:7: error: expected ';' before 'last'
   27 |     ll last=n+1;
      |       ^~~~~
      |       ;
books.cpp:29:9: error: 's' was not declared in this scope
   29 |         s-=v[i];
      |         ^
books.cpp:29:12: error: 'v' was not declared in this scope
   29 |         s-=v[i];
      |            ^
books.cpp:30:11: error: expected ';' before 'p'
   30 |         ll p=i,f=last;
      |           ^~
      |           ;
books.cpp:31:19: error: 'p' was not declared in this scope
   31 |         while(abs(p-f)!=1){
      |                   ^
books.cpp:31:21: error: 'f' was not declared in this scope
   31 |         while(abs(p-f)!=1){
      |                     ^
books.cpp:32:15: error: expected ';' before 'md'
   32 |             ll md=(p+f)/2;
      |               ^~~
      |               ;
books.cpp:33:18: error: 'md' was not declared in this scope
   33 |             if(v[md]==0)v[md]=skim(md);
      |                  ^~
books.cpp:34:20: error: 'md' was not declared in this scope
   34 |             if(s+v[md]<A)p=md;
      |                    ^~
books.cpp:37:21: error: 'r' was not declared in this scope
   37 |                     r[i-1]=md;
      |                     ^
books.cpp:42:9: error: 'r' was not declared in this scope
   42 |         r[i-1]=p;
      |         ^
books.cpp:42:16: error: 'p' was not declared in this scope
   42 |         r[i-1]=p;
      |                ^
books.cpp:44:9: error: 'last' was not declared in this scope
   44 |         last=p;
      |         ^~~~