Submission details
Task:Hamilton
Sender:jsesok
Submission time:2026-04-17 13:45:53 +0300
Language:C++ (C++20)
Status:READY
Result:0
Feedback
subtaskverdictscore
#10
#20
#30
#40
Test results
testverdicttimescoresubtask
#10.01 s0details
#20.01 s01details
#30.04 s02, 3details
#40.31 s04details

Code

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <queue>
#include <climits>
#include <map>
#include <unordered_map>
#include <stack>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n, t, x;
    cin>>n>>t;
    string a;
    char c;

    for (int i=0; i<n; ++i)
    {
        for (int j=0; j<n; ++j)
        {
            if (j<=i)
                cout<<0;
            else
                cout<<1;
        }
        cout<<endl;
    }
    while (--t)
    {
    vector<vector<int>> b(n);
    for (int i=1; i<=n; ++i)
    {
        for (int j=i+1; j<=n; ++j)
        {
            cout<<"? "<<i<<" "<<j<<endl;
            cin>>c;
            if (c=='>')
            {
                b[i-1].push_back(j-1);
            }
            else
            {
                b[j-1].push_back(i-1);
            }
        }
    }
    vector<pair<int, int>> d(n);
    for (int i=0; i<n; ++i)
    {
        queue<int> q;
        for (int j=0; j<n; ++j)
            d[j]={-1, -1};
        d[i]={1, -1};
        q.push(i);
        x=-1;
        while (!q.empty())
        {
            for (int j : b[q.front()])
            {
                if (d[j].first==1 && d[q.front()].first==n)
                {
                    x=q.front();
                    break;
                }
                if (d[j].first==-1)
                {
                    d[j]={d[q.front()].first+1, q.front()};
                }
            }
            q.pop();
            if (x!=-1)
                break;
        }
        if (x!=-1)
            break;
    }
    cout<<"!";
    stack<int> s;
    while (d[x].second!=-1)
    {
        s.push(x);
        x=d[x].second;
    }
    while (!s.empty())
    {
        cout<<" "<<s.top()+1;
        s.pop();
    }
    cout<<endl;
    }
    return 0;
}

Test details

Test 1

Subtask:

Verdict:

input
0 5 2 fixed 1 2 3 4 5 2 4 1 5 ...

correct output
(empty)

user output
Activating encoder mode
5 2
01111
00111
00011
...

Feedback: Case #1: Invalid node in answer

Test 2

Subtask: 1

Verdict:

input
01 4 200 rnd

correct output
(empty)

user output
Activating encoder mode
4 200
0111
0011
0001
...

Feedback: Case #1: Invalid node in answer

Test 3

Subtask: 2, 3

Verdict:

input
02 50 200 rnd

correct output
(empty)

user output
Activating encoder mode
50 200
011111111111111111111111111111...

Feedback: Case #1: Invalid node in answer

Test 4

Subtask: 4

Verdict:

input
03 500 200 rnd

correct output
(empty)

user output
Activating encoder mode
500 200
011111111111111111111111111111...

Feedback: Case #1: Too many queries