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

I Tried Phone Stand For Desk For 30 Days Here Is the Honest Truth

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

Stop Buying Cheap Alternatives This Wireless Earbuds Accessories Is the Real Deal

📢 As an Amazon Associate, I earn from qualifying purchases.I stumbled across this while desperately trying to fix a recurring problem in my routine....

Where the OKC Thunder Rank Among the Top 10 NBA Teams Entering August

As the offseason progresses into August, the NBA landscape continues to undergo dramatic transformations. Major headline-grabbing moves, including LeBron James making his historic transition...

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!