제출 #104047

#제출 시각아이디문제언어결과실행 시간메모리
104047RockyB커다란 상품 (IOI17_prize)C++17
97.75 / 100
47 ms2048 KiB
#include "prize.h" #include <bits/stdc++.h> #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define MP make_pair #define F first #define S second #define ET cout << "\n" #define MEM(i,j) memset(i,j,sizeof i) #define ALL(v) v.begin(),v.end() #define DB(a,s,e) {for(int i=s;i<e;++i) cerr << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; pii arr[200005]; pii query(int x) { if(~arr[x].F) return arr[x]; auto v=ask(x); return arr[x]=MP(v[0],v[1]); } int search(int l,int r) { if(r-l<=1) return -1; int m=l+r>>1; pii a=query(l),b=query(r),t=query(m); if(t==MP(0,0)) return m; if((t.F==a.F)||!t.F) return search(m,r); if((t.F==b.F)||!t.S) return search(l,m); if(rand()%2) { int df=search(l,m); if(~df) return df; return search(m,r); } int df=search(m,r); if(~df) return df; return search(l,m); } int find_best(int n) { fill(arr,arr+n,MP(-1,-1)); int ans = search(0,n-1); if (~ans) return ans; if(query(0)==MP(0,0)) return 0; if(query(n-1)==MP(0,0)) return n-1; }

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

prize.cpp: In function 'int search(int, int)':
prize.cpp:28:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int m=l+r>>1;
        ~^~
prize.cpp: In function 'int find_best(int)':
prize.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...