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

How Viral Kitchen Gadgets Is Quietly Changing the Game

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

Is Viral Kitchen Gadgets Worth Your Money Here Is Our Full Review

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

Putin approves takeover of French and Swiss giants’ Russian assets. Why now?

In a major development regarding foreign corporate ownership in Russia, President Vladimir Putin has authorized a decree placing the local subsidiaries of prominent Swiss...

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!