제출 #699401

#제출 시각아이디문제언어결과실행 시간메모리
699401MasterTaster커다란 상품 (IOI17_prize)C++14
20 / 100
84 ms464 KiB
#include "prize.h" #include <iostream> #include <vector> #include <cmath> #define ll long long #define pii pair<int, int> #define xx first #define yy second #define pb push_back #define MAXN 200010 using namespace std; int n, l[MAXN], r[MAXN], maxx, sq=480; vector<int> all; bool check(int i, int k) { vector<int> p=ask(i); int le=p[0], ri=p[1]; if ((le+ri)<maxx) return true; if (le>k) return true; return false; } bool vis[200010]; vector<int> askk(int i) { if (!vis[i]) { vector<int> p=ask(i); l[i]=p[0]; r[i]=p[1]; vis[i]=true; return p; } else { vector<int> p={l[i], r[i]}; return p; } } void solve(int left, int right) { int mid=left+(right-left)/2; vector<int> p=askk(mid); int le=p[0]; int ri=p[1]; if (left==right) { if ((le+ri)<maxx) all.pb(mid); return; } if (left==(right-1)) { if ((le+ri)<maxx) all.pb(mid); mid++; vector<int> p=askk(mid); if ((p[0]+p[1])<maxx) all.pb(mid); return; } if ((le+ri)<maxx) { all.pb(mid); solve(left, mid-1); solve(mid+1, right); } else { if (le) solve(left, mid-1); if (ri) solve(mid+1, right); } } int find_best(int N) { n=N; sq=min(sq, n-1);//2*sqrt(n); for (int i=0; i<=min(n-1, sq); i++) { vector<int> p=askk(i); l[i]=p[0]; r[i]=p[1]; maxx=max(maxx, l[i]+r[i]); } int left=0, right=n-1; solve(left, right); /*int lf=0; int rr=n-1; for (int i=0; i<maxx; i++) { int where=-1; while (lf<=rr) { int mid=lf+(rr-lf)/2; if (check(mid, all.size())) { where=mid; rr=mid-1; } else lf=mid+1; } //cout<<where<<endl; all.pb(where); lf=where+1; rr=n-1; }*/ int ret=0; for (int i=0; i<all.size(); i++) { vector<int> p=askk(all[i]); if ((p[0]+p[1])==0) ret=all[i]; } return ret; } ///1, 2, 5, 26, 677 /* 8 3 2 3 1 3 3 2 3 */

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:91:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |     for (int i=0; i<all.size(); i++) { vector<int> p=askk(all[i]); if ((p[0]+p[1])==0) ret=all[i]; }
      |                   ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...