제출 #431481

#제출 시각아이디문제언어결과실행 시간메모리
431481Belgutei커다란 상품 (IOI17_prize)C++17
20 / 100
130 ms1000 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair vector<int> v; map<int,pair<int,int> > mp; bool check[200005]; int ans,mx,N; void dfs(int x, int y){ if(x>y) return; int a,b,c,d; if(check[x]==1){ a=mp[x].ff; b=mp[x].ss; } else{ vector<int> v1=ask(x); a=v1[0]; b=v1[1]; check[x]=1; mp[x].ff=a; mp[x].ss=b; } if(x==y){ if(a+b!=mx) v.pb(x); return; } if(check[y]==1){ c=mp[y].ff; d=mp[y].ss; } else{ vector<int> v2=ask(y); c=v2[0]; d=v2[1]; mp[y].ff=c; mp[y].ss=d; check[y]=1; } if(a+b==mx && c+d==mx){ if(c-a==0 || y-x==1) return; int mid=(x+y)/2; dfs(x,mid); dfs(mid+1,y); } else{ if(a+b<mx && c+d<mx){ v.pb(x); v.pb(y); if(y-x>=2){ int mid=((y-1)+(x+1)/2); dfs(x,mid); dfs(mid+1,y); } return; } if(a+b<mx){ v.pb(x); if(x+1<y){ int mid=(x+1+y)/2; dfs(x+1,mid); dfs(mid+1,y); } return; } v.pb(y); if(x<y-1){ int mid=(x-1+y)/2; dfs(x,mid); dfs(mid+1,y-1); } } } int find_best(int n) { for(int i=0; i<min(480,n); i++){ vector<int> vv; vv=ask(i); check[i]=1; mp[i].ff=vv[0]; mp[i].ss=vv[1]; mx=max(mx,vv[0]+vv[1]); } int l=0; int r=n-1; dfs(l,r); for(int i=0; i<v.size(); i++){ vector<int> vv; vv=ask(v[i]); if(vv[0]==0 && vv[1]==0){ return v[i]; } } return ans; }

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

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