답안 #33301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
33301 2017-10-23T09:46:34 Z model_code 커다란 상품 (IOI17_prize) C++11
100 / 100
78 ms 2292 KB
#include<bits/stdc++.h>
#include "prize.h"
#define X first
#define Y second
using namespace std;

typedef pair<int,int> pii;

int numb, q_count = 4999;
pii P[210000];
bool mark[210000];
vector<int>vtmp;

pii query(int x)
{
  if(mark[x]) return P[x];
  mark[x]=true;
  q_count --;
  vtmp=ask(x);
  pii tmp=pii(vtmp[0],vtmp[1]);
  if(tmp.X+tmp.Y==0) throw x;
  return P[x]=tmp;
}

void bs(int l,int r,int nl,int nr)
{
  if(l>r) return;
  for(int i=0;i<=r-l;i++)
    {
      int mid,midl=(l+r)/2-i/2,midr=(l+r)/2+(i+1)/2;
      if(i%2==0) mid=midl;
      else mid=midr;
      pii tmp=query(mid);
      if(tmp.X+tmp.Y==numb)
	{
	  int tmpl=(i%2==0?0:midr-midl);
	  int tmpr=(i%2==1?0:midr-midl);
	  if(tmp.X-tmpl>nl) bs(l,midl-1,nl,tmp.Y+tmpl);
	  if(tmp.Y-tmpr>nr) bs(midr+1,r,tmp.X+tmpr,nr);
	  break;
	}
    }
}

int find_best(int n)
{
  if(n==1) return 0;
  try{
    numb=0;
    memset(mark,false,sizeof mark);
    int p=0;
    for(int i=0;i<sqrt(n)+30 && i<n && numb<27;i++)
      {
	pii tmp=query(i);
	if(tmp.X+tmp.Y>numb) p=i;
	numb=max(numb,tmp.X+tmp.Y);
      }
    bs(p,n-1,p,0);
  }
  catch(int ans){
    for(int i=0;i<q_count;i++)
      ask(0);
    return ans;
  }
  return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 700 KB Output is correct
2 Correct 50 ms 748 KB Output is correct
3 Correct 43 ms 620 KB Output is correct
4 Correct 45 ms 620 KB Output is correct
5 Correct 52 ms 620 KB Output is correct
6 Correct 43 ms 620 KB Output is correct
7 Correct 44 ms 620 KB Output is correct
8 Correct 41 ms 620 KB Output is correct
9 Correct 54 ms 708 KB Output is correct
10 Correct 42 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 708 KB Output is correct
2 Correct 38 ms 620 KB Output is correct
3 Correct 46 ms 620 KB Output is correct
4 Correct 64 ms 748 KB Output is correct
5 Correct 41 ms 620 KB Output is correct
6 Correct 43 ms 620 KB Output is correct
7 Correct 40 ms 620 KB Output is correct
8 Correct 67 ms 620 KB Output is correct
9 Correct 74 ms 620 KB Output is correct
10 Correct 43 ms 620 KB Output is correct
11 Correct 62 ms 876 KB Output is correct
12 Correct 47 ms 620 KB Output is correct
13 Correct 46 ms 1300 KB Output is correct
14 Correct 62 ms 620 KB Output is correct
15 Correct 55 ms 876 KB Output is correct
16 Correct 49 ms 1992 KB Output is correct
17 Correct 62 ms 620 KB Output is correct
18 Correct 45 ms 2156 KB Output is correct
19 Correct 46 ms 620 KB Output is correct
20 Correct 40 ms 992 KB Output is correct
21 Correct 49 ms 1260 KB Output is correct
22 Correct 54 ms 876 KB Output is correct
23 Correct 28 ms 708 KB Output is correct
24 Correct 40 ms 744 KB Output is correct
25 Correct 58 ms 1536 KB Output is correct
26 Correct 51 ms 1388 KB Output is correct
27 Correct 44 ms 636 KB Output is correct
28 Correct 52 ms 2156 KB Output is correct
29 Correct 40 ms 1900 KB Output is correct
30 Correct 51 ms 2156 KB Output is correct
31 Correct 29 ms 704 KB Output is correct
32 Correct 41 ms 1132 KB Output is correct
33 Correct 66 ms 620 KB Output is correct
34 Correct 44 ms 1132 KB Output is correct
35 Correct 44 ms 876 KB Output is correct
36 Correct 48 ms 1004 KB Output is correct
37 Correct 77 ms 748 KB Output is correct
38 Correct 56 ms 748 KB Output is correct
39 Correct 52 ms 1388 KB Output is correct
40 Correct 47 ms 2156 KB Output is correct
41 Correct 48 ms 1516 KB Output is correct
42 Correct 59 ms 1516 KB Output is correct
43 Correct 49 ms 1644 KB Output is correct
44 Correct 53 ms 1260 KB Output is correct
45 Correct 68 ms 1000 KB Output is correct
46 Correct 52 ms 620 KB Output is correct
47 Correct 65 ms 1260 KB Output is correct
48 Correct 44 ms 1772 KB Output is correct
49 Correct 67 ms 748 KB Output is correct
50 Correct 45 ms 2292 KB Output is correct
51 Correct 59 ms 1388 KB Output is correct
52 Correct 78 ms 704 KB Output is correct
53 Correct 44 ms 748 KB Output is correct
54 Correct 49 ms 1260 KB Output is correct
55 Correct 52 ms 696 KB Output is correct
56 Correct 38 ms 2188 KB Output is correct
57 Correct 35 ms 1724 KB Output is correct
58 Correct 47 ms 1812 KB Output is correct
59 Correct 62 ms 1516 KB Output is correct
60 Correct 61 ms 1516 KB Output is correct
61 Correct 50 ms 852 KB Output is correct
62 Correct 46 ms 620 KB Output is correct
63 Correct 44 ms 764 KB Output is correct
64 Correct 41 ms 748 KB Output is correct
65 Correct 36 ms 748 KB Output is correct
66 Correct 56 ms 632 KB Output is correct
67 Correct 43 ms 620 KB Output is correct
68 Correct 47 ms 620 KB Output is correct
69 Correct 28 ms 744 KB Output is correct
70 Correct 64 ms 620 KB Output is correct
71 Correct 40 ms 2184 KB Output is correct
72 Correct 42 ms 1260 KB Output is correct
73 Correct 30 ms 2208 KB Output is correct
74 Correct 30 ms 2204 KB Output is correct
75 Correct 47 ms 876 KB Output is correct
76 Correct 49 ms 2156 KB Output is correct
77 Correct 62 ms 2156 KB Output is correct
78 Correct 66 ms 1260 KB Output is correct
79 Correct 66 ms 2028 KB Output is correct
80 Correct 51 ms 2156 KB Output is correct
81 Correct 49 ms 2156 KB Output is correct
82 Correct 36 ms 2220 KB Output is correct
83 Correct 50 ms 876 KB Output is correct
84 Correct 52 ms 2156 KB Output is correct
85 Correct 30 ms 2240 KB Output is correct
86 Correct 41 ms 620 KB Output is correct
87 Correct 59 ms 620 KB Output is correct
88 Correct 62 ms 620 KB Output is correct
89 Correct 45 ms 620 KB Output is correct
90 Correct 44 ms 620 KB Output is correct
91 Correct 51 ms 748 KB Output is correct
92 Correct 43 ms 620 KB Output is correct
93 Correct 39 ms 1004 KB Output is correct
94 Correct 52 ms 1132 KB Output is correct
95 Correct 60 ms 1192 KB Output is correct
96 Correct 57 ms 1048 KB Output is correct
97 Correct 47 ms 896 KB Output is correct