Submission #1089689

# Submission time Handle Problem Language Result Execution time Memory
1089689 2024-09-16T22:16:53 Z urd05 The Big Prize (IOI17_prize) C++17
Compilation error
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

P save[200005];
typedef pair<int,int> P;
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: In function 'P query(int)':
prize.cpp:10:9: error: 'save' was not declared in this scope
   10 |     if (save[i].first!=-1) {
      |         ^~~~
prize.cpp:14:12: error: 'save' was not declared in this scope
   14 |     return save[i]=P(got[0],got[1]);
      |            ^~~~
prize.cpp: At global scope:
prize.cpp:19:23: error: expected ',' or '...' before '.' token
   19 | void solve(int l,int r.int k,int y) {
      |                       ^
prize.cpp: In function 'void solve(int, int)':
prize.cpp:26:23: error: 'y' was not declared in this scope
   26 |         solve(l,mid-1,y-got.second,y);
      |                       ^
prize.cpp:27:23: error: 'k' was not declared in this scope
   27 |         solve(mid+1,r,k-(y-got.second),got.second);
      |                       ^
prize.cpp:35:25: error: 'y' was not declared in this scope
   35 |             solve(l,i-1,y-got.second,y);
      |                         ^
prize.cpp:36:27: error: 'k' was not declared in this scope
   36 |             solve(mid+1,r,k-(y-got.second)-cnt,got.second-cnt);
      |                           ^
prize.cpp:40:19: error: 'k' was not declared in this scope
   40 |     solve(mid+1,r,k-cnt,y-cnt);
      |                   ^
prize.cpp:40:25: error: 'y' was not declared in this scope
   40 |     solve(mid+1,r,k-cnt,y-cnt);
      |                         ^
prize.cpp: In function 'int find_best(int)':
prize.cpp:46:6: error: 'save' was not declared in this scope
   46 |      save[i]=P(-1,-1);
      |      ^~~~