AC_in_the_dark's blog

By AC_in_the_dark, history, 6 weeks ago, In English

D. Dragon Balls

It's an interactive problem. One code can pass, but the other one got "Wrong answer on test 14". I tried test 14 locally. It seems that it can give the right answer. Does anyone know what's wrong with it?

By the way, I don't know if I should use something like cout.flush() for interactive problems. It seems that some submissions passed without any cout.flush() or endl. (They simply use "\n" to type a new line.) So should I pay attention to flush my output in such cases?

//WA code
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL x, y;
signed main()
{
    int T; cin >> T;
    while(T--)
    {
        cout << "0 0" << endl;
        LL d1; cin >> d1;
        if(!d1) continue;
        cout << "1 0" << endl;
        LL d2; cin >> d2;
        if(!d2) continue;
        if(d1 < d2)
        {
            x = 0; y = sqrt(d1);
            cout << x << " " << y << endl;
        }
        else
        {
            x = d1 - d2 + 1 >> 1; y = sqrt(d1- x*x);
            cout << x << " " << y << endl;
        }
        cin >> d1;
    }

	return 0;
}
//AC code
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
signed main()
{
    int T; cin >> T;
    while(T--)
    {
        cout << "0 0" << endl;
        LL d1; cin >> d1;
        if(!d1) continue;
        cout << "1 0" << endl;
        LL d2; cin >> d2;
        if(!d2) continue;
        cout << "0 1" << endl;
        LL d3; cin >> d3;
        if(!d3) continue;
        LL x = d1 - d2 + 1 >> 1;
        cout << x << " " << (LL)sqrt(d1 - x*x) << endl;
        cin >> d2;
        if(!d2) continue;
        LL y = d1 - d3 + 1 >> 1;
        cout << (LL)sqrt(d1 - y*y) << " " << y << endl;
        cin >> d3;
    }

	return 0;
}
 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by AC_in_the_dark (previous revision, new revision, compare).

»
6 weeks ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

The codes you provided are from the gym, and I can't simply look at them. Maybe you could send them via the contest upsolving instead of the gym?

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I'm sorry, but I can't find the corresponding contest on codeforces. Can you view the codes here? Or shall I paste them directly right here?

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Here would be great, too. Pastebin codes shall expire someday.

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Thank you for your advice. The codes are now shown in the article.

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by AC_in_the_dark (previous revision, new revision, compare).