-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMAXEP.cpp
More file actions
61 lines (53 loc) · 1.01 KB
/
MAXEP.cpp
File metadata and controls
61 lines (53 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<iostream>
using namespace std;
int main()
{
int n,c;
cin>>n>>c;
int ans=0;
int low=1,high=n;
int mid;
int y;
int count=0;
//int a[n+1]={0};
int cost=1000;
int flag=0;
while(low<=high&&cost>0)
{
mid=(low+high)/2;
y=mid;
cout<<1<<" "<<y<<"\n";
cout.flush();
cin>>y;
if(y==0)
{ count++;
low=mid+1;
cost--;
if(mid==ans&&count!=1)
break;
ans=mid;
}
else if(y==1)
{
cost--;
high=mid-1;
if(cost-c>=0&&flag==0)
{
cost-=c;
cout<<2<<"\n";
cout.flush();
}
else
{
flag=1;
}
}
else
{
cost--;
high=mid;
}
}
cout<<3<<" "<<ans+1;
cout.flush();
}