Codeforces Round #415 (Div. 2), problem: (D) Glad to see you! Solution In C/C++

#include <cstdio>
using namespace std;
#define ff fflush(stdout)
#define mid (lef+rig>>1)
int n, k, x, t1, t2; char s[5];
inline bool I(int a, int b){printf(“1 %d %d\n”,a,b), ff, scanf(“%s”,s); return s[0]==’T’;}
inline int Binary(int lef, int rig){if(lef>rig) return 0; for(; rig-lef > 1; I(mid,mid+1) ? rig = mid : lef = mid+1); return (lef==rig || I(lef,rig)) ? lef : rig;}
int main(){scanf(“%d %d”,&n,&k), n-2 ? x=Binary(1,n), t2 = Binary(x+1,n), t1 = Binary(1,x-1), printf(“2 %d %d\n”,x,t1&&t2 ? I(t1,t2)?t1:t2 : t1+t2) : puts(“2 1 2”); ff; return 0;}

#include <cstdio>
using namespace std;
#define ff fflush(stdout)
#define mid (lef+rig>>1)
int n, k, x, t1, t2; char s[5];
inline bool I(int a, int b){printf(“1 %d %d\n”,a,b), ff, scanf(“%s”,s); return s[0]==’T’;}
inline int Binary(int lef, int rig){if(lef>rig) return 0; for(; rig-lef > 1; I(mid,mid+1) ? rig = mid : lef = mid+1); return (lef==rig || I(lef,rig)) ? lef : rig;}
int main(){scanf(“%d %d”,&n,&k), n-2 ? x=Binary(1,n), t2 = Binary(x+1,n), t1 = Binary(1,x-1), printf(“2 %d %d\n”,x,t1&&t2 ? I(t1,t2)?t1:t2 : t1+t2) : puts(“2 1 2”); ff; return 0;}

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

Everything You Need to Know About Viral Kitchen Gadgets Right Now

📢 As an Amazon Associate, I earn from qualifying purchases.Most products in this category disappoint within weeks. Cheap materials, vague instructions, and results that...

How do birds know when you put out bird seed?

If you have ever refilled your backyard bird feeder, you have likely noticed a curious phenomenon: within minutes of setting out fresh seeds, a...

7 Reasons This Viral Kitchen Gadgets Is Worth Every Single Penny

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!