제출 #283961

#제출 시각아이디문제언어결과실행 시간메모리
283961erd1커다란 상품 (IOI17_prize)C++14
20 / 100
3061 ms2088 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() typedef pair<int, int> pii; typedef long long lld; typedef long double ld; vector<pii> queries; set<int> sums; // total 5 pii query(int x){ if(queries[x].ff != -1)return queries[x]; vector<int> res = ask(x); queries[x] = {res[0], res[1]}; sums.insert(res[0] + res[1]); return queries[x]; } int sum(pii a){ return a.ff + a.ss; } void finds(int n, int k){ int l = 0, r = n; while(true){ int lmd = l+r>>1, rmd = lmd; while(rmd < n && next(sums.find(sum(query(rmd)))) != sums.end()) rmd++; while(lmd >= 0 && next(sums.find(sum(query(lmd)))) != sums.end()) lmd--; for(int i = lmd; i < rmd; i++)if(query(i).ff + query(i).ss == 0)throw i; if(rmd == n || lmd < 0)return; if(query(rmd).ff > k && query(lmd).ff <= k)return; (query(lmd).ff > k?r:l) = lmd; } } int find_best(int n) { queries.resize(n, {-1, -1}); try{ for(int i = 0; i < 6; i++) for(int j = 0; j < 2000; j++)finds(n, j); }catch(int e){ return e; } }

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

prize.cpp: In function 'void finds(int, int)':
prize.cpp:29:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   29 |   int lmd = l+r>>1, rmd = lmd;
      |             ~^~
prize.cpp: In function 'int find_best(int)':
prize.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...