제출 #1113314

#제출 시각아이디문제언어결과실행 시간메모리
1113314epicci23커다란 상품 (IOI17_prize)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #include "prize.h" //#define int long long #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() using namespace std; const int S = 100; const int S2 = 20; int ask_all(int l,int r){ for(int i=l;i<=r;i++){ auto x = ask(i); if(x[0]+x[1]==0) return i; } return -23; } int find_best(int n){ if(n<=1000) return ask_all(0,n-1); int L = -1; array<int,2> Cache; for(int i=0;i<500;i++){ array<int,2> x = ask(i); if(x[0]+x[1]==0) return i; if(L==-1){ L=i; Cache=x; } else if(x[0]+x[1]>Cache[0]+Cache[1]){ L=i; Cache=x; } } while(L+S<n){ array<int,2> x = ask(L+S); if(x[0]+x[1]==0) return L+S; if(x[0]+x[1]==Cache[0]+Cache[1] && Cache[1]==x[1]){ L+=S; continue; } int p = L; while(p+S2<L+S){ p+=S2; array<int,2> u = ask(p); if(u[0]+u[1]==0) return p; if(u[0]+u[1]==Cache[0]+Cache[1] && Cache[1]==u[1]) continue; else{ int xd = ask_all(p-S2+1,p-1); if(xd!=-23) return xd; } } int xd = ask_all(p+1,L+S-1); if(xd!=-23) return xd; L+=S; } return ask_all(L+1,n-1); }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:25:25: error: conversion from 'std::vector<int>' to non-scalar type 'std::array<int, 2>' requested
   25 |     array<int,2> x = ask(i);
      |                      ~~~^~~
prize.cpp:38:25: error: conversion from 'std::vector<int>' to non-scalar type 'std::array<int, 2>' requested
   38 |     array<int,2> x = ask(L+S);
      |                      ~~~^~~~~
prize.cpp:47:27: error: conversion from 'std::vector<int>' to non-scalar type 'std::array<int, 2>' requested
   47 |       array<int,2> u = ask(p);
      |                        ~~~^~~