QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#332430#8239. Mysterious TreeA1922WA 3ms3684kbC++142.8kb2024-02-19 15:24:162024-02-19 15:24:16

Judging History

你现在查看的是最新测评结果

  • [2024-02-19 15:24:16]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3684kb
  • [2024-02-19 15:24:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int j,f=0;
        int an;
        int n;
        cin>>n;
        for(int i=1; i<n; i+=2)
        {
            j=i+1;
            cout<<"?"<<' '<<i<<' '<<j<<endl;
            cout.flush();
            cin>>an;
            if(an==1)
            {
                f=1;
                break;
            }
        }
        if(f==1)
        {
            if(j>3)
            {
                cout<<'?'<<' '<<j<<' '<<j-2<<endl;
                cout.flush();
                cin>>an;
                if(an==1)
                {
                    cout<<'?'<<' '<<j<<' '<<j-3<<endl;
                    cout.flush();
                    cin>>an;
                    if(an==1)f=1;
                    else f=0;
                }
                else
                {
                    cout<<'?'<<' '<<j-1<<' '<<j-2<<endl;
                    cout.flush();
                    cin>>an;
                    if(an==1)
                    {
                        cout<<'?'<<' '<<j-1<<' '<<j-3<<endl;
                        cout.flush();
                        cin>>an;
                        if(an==1)f=1;
                        else f=0;
                    }
                    else f=0;
                }
            }
            else
            {
                cout<<'?'<<' '<<j<<' '<<j+2<<endl;
                cout.flush();
                cin>>an;
                if(an==1)
                {
                    cout<<'?'<<' '<<j<<' '<<j+1<<endl;
                    cout.flush();
                    cin>>an;
                    if(an==1)f=1;
                    else f=0;
                }
                else
                {
                    cout<<'?'<<' '<<j-1<<' '<<j+2<<endl;
                    cout.flush();
                    cin>>an;
                    if(an==1)
                    {
                        cout<<'?'<<' '<<j-1<<' '<<j+1<<endl;
                        cout.flush();
                        cin>>an;
                        if(an==1)f=1;
                        else f=0;
                    }
                    else f=0;
                }
            }

        }
        else if(n%2==1)
        {
            cout<<'?'<<' '<<n<<' '<<n-1<<endl;
            cout.flush();
            cin>>an;
            if(an==1)
            {
                cout<<'?'<<' '<<n<<' '<<n-2<<endl;
                cout.flush();
                cin>>an;
                if(an==1)f=1;
                else f=0;
            }
            else f=0;
        }
        if(f==1)cout<<'!'<<' '<<'2'<<endl;
        else cout<<'!'<<' '<<'1'<<endl;
        cout.flush();

    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3540kb

input:

2
4
1
0
0
4
0
1
0
1
1

output:

? 1 2
? 2 4
? 1 4
! 1
? 1 2
? 3 4
? 4 2
? 3 2
? 3 1
! 2

result:

ok Correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3684kb

input:

87
13
0
0
0
0
0
1
1
1
15
0
0
0
0
0
0
1
0
1
1
7
0
0
0
1
1
15
0
0
0
1
0
0
19
0
0
0
0
0
1
0
1
1
20
0
0
0
0
0
0
0
0
0
0
7
0
0
1
1
1
20
0
0
0
0
0
0
0
1
0
1
1
17
0
0
0
0
0
0
0
0
0
11
1
1
0
14
0
0
0
0
0
0
0
13
0
0
0
0
0
0
0
18
0
0
0
0
0
1
1
1
14
0
1
1
1
20
0
0
0
0
1
0
0
11
0
0
0
1
0
1
0
11
0
1
0
0
8
0
1
0
...

output:

? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 12 10
? 12 9
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 13 14
? 14 12
? 13 12
? 13 11
! 2
? 1 2
? 3 4
? 5 6
? 7 6
? 7 5
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 8 6
? 7 6
! 1
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 12 10
? 11 10
? 11 9
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 9...

result:

wrong answer Wrong prediction (test case 56)