Why i’m getting wrong answer for the problem “Guess The Number(Interactive problem)” if i use ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
Link for the problem: CodeChef: Practical coding for everyone
My solution for the problem :
NOTE: This code is giving WA;
using namespace std;
#include<bits/stdc++.h>
using ll=long long int;
#define endl “\n”
#define pb push_back
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
vector<ll>v;
for(ll i=1;i<1001;i++)
v.push_back(i*i);
ll t,ans;
cin>>t;
while(t--)
{
for(ll i=0;i<1000;i++)
{
cout<<v[i]<<endl;
cin>>ans;
if(ans==1)break;
}
}
}
But the following gives AC
using namespace std;
#include<bits/stdc++.h>
using ll=long long int;
#define endl “\n”
#define pb push_back
int main()
{
// ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
vector<ll>v;
for(ll i=1;i<1001;i++)
v.push_back(i*i);
ll t,ans;
cin>>t;
while(t--)
{
for(ll i=0;i<1000;i++)
{
cout<<v[i]<<endl;
cin>>ans;
if(ans==1)break;
}
}
} Only difference in both code is the use of fast I/O.
so ,why cant we use fast I/O for interactive problems?