답안 #1089688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089688 2024-09-16T22:16:27 Z urd05 커다란 상품 (IOI17_prize) C++17
컴파일 오류
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

P save[200005];
int n;

P query(int i) {
    if (save[i].first!=-1) {
        return save[i];
    }
    vector<int> got=ask(i);
    return save[i]=P(got[0],got[1]);
}

vector<int> vec;

void solve(int l,int r.int k,int y) {
    if (l>r) {
        return;
    }
    int mid=(l+r)/2;
    P got=query(mid);
    if (got.first+got.second==n-1) {
        solve(l,mid-1,y-got.second,y);
        solve(mid+1,r,k-(y-got.second),got.second);
        return;
    }
    vec.push_back(mid);
    int cnt=1;
    for(int i=mid-1;i>=l;i--) {
        P got=query(i);
        if (got.first+got.second==n-1) {
            solve(l,i-1,y-got.second,y);
            solve(mid+1,r,k-(y-got.second)-cnt,got.second-cnt);
            return;
        }
    }
    solve(mid+1,r,k-cnt,y-cnt);
}

int find_best(int N) {
    n=N;
	for(int i = 0; i < n; i++) {
	    save[i]=P(-1,-1);
	}
	solve(0,n-1);
	for(int x:vec) {
	    if (query(x)==P(0,0)) {
	        return x;
	    }
	}
	return 0;
}

Compilation message

prize.cpp:5:1: error: 'P' does not name a type
    5 | P save[200005];
      | ^
prize.cpp:8:1: error: 'P' does not name a type
    8 | P query(int i) {
      | ^
prize.cpp:18:23: error: expected ',' or '...' before '.' token
   18 | void solve(int l,int r.int k,int y) {
      |                       ^
prize.cpp: In function 'void solve(int, int)':
prize.cpp:23:5: error: 'P' was not declared in this scope
   23 |     P got=query(mid);
      |     ^
prize.cpp:24:9: error: 'got' was not declared in this scope
   24 |     if (got.first+got.second==n-1) {
      |         ^~~
prize.cpp:25:23: error: 'y' was not declared in this scope
   25 |         solve(l,mid-1,y-got.second,y);
      |                       ^
prize.cpp:26:23: error: 'k' was not declared in this scope
   26 |         solve(mid+1,r,k-(y-got.second),got.second);
      |                       ^
prize.cpp:32:10: error: expected ';' before 'got'
   32 |         P got=query(i);
      |          ^~~~
      |          ;
prize.cpp:33:13: error: 'got' was not declared in this scope
   33 |         if (got.first+got.second==n-1) {
      |             ^~~
prize.cpp:34:25: error: 'y' was not declared in this scope
   34 |             solve(l,i-1,y-got.second,y);
      |                         ^
prize.cpp:35:27: error: 'k' was not declared in this scope
   35 |             solve(mid+1,r,k-(y-got.second)-cnt,got.second-cnt);
      |                           ^
prize.cpp:39:19: error: 'k' was not declared in this scope
   39 |     solve(mid+1,r,k-cnt,y-cnt);
      |                   ^
prize.cpp:39:25: error: 'y' was not declared in this scope
   39 |     solve(mid+1,r,k-cnt,y-cnt);
      |                         ^
prize.cpp: In function 'int find_best(int)':
prize.cpp:45:6: error: 'save' was not declared in this scope
   45 |      save[i]=P(-1,-1);
      |      ^~~~
prize.cpp:45:14: error: 'P' was not declared in this scope
   45 |      save[i]=P(-1,-1);
      |              ^
prize.cpp:49:10: error: 'query' was not declared in this scope
   49 |      if (query(x)==P(0,0)) {
      |          ^~~~~
prize.cpp:49:20: error: 'P' was not declared in this scope
   49 |      if (query(x)==P(0,0)) {
      |                    ^