Submission details
Task:Hamilton
Sender:Juan_Alejandro
Submission time:2026-04-17 11:40:42 +0300
Language:C++ (C++20)
Status:READY
Result:5
Feedback
subtaskverdictscore
#1ACCEPTED5
#20
#30
#40
Test results
testverdicttimescoresubtask
#1ACCEPTED0.01 s100details
#2ACCEPTED0.04 s1001details
#30.28 s02, 3details
#40.32 s04details

Code

#include <bits/stdc++.h>
#define int long long 
//#define endl " \n"
#define vec vector 
#define all(x) x.begin(),x.end()
#pragma GCC optimize("O2,unroll-loops")
using namespace std;
bool query(int u,int v)
{
    cout<<"? "<<u<<" "<<v<<endl;
    char c;
    cin>>c;
    return c=='>';
}
stack<int> res;
void dfs(int u,int &n,vec<bool> vis,bool &enc,int c)
{
    vis[u]=1;
    if(c==n&&query(u,1))
    {
        enc=1;
        //res.push(1);
        res.push(u);
        return;
    }
    for(int v=1;v<=n;v++)
    {
        if((!vis[v])&&query(u,v))
        {
            //cout<<"going to:"<<v<<" from:"<<u<<" \n";
            dfs(v,n,vis,enc,c+1);
            if(enc)
            {
                res.push(u);
                return;
            }
        }
    }
    
}
int32_t main()
{
    /*ios::sync_with_stdio(false);
    cin.tie(nullptr);*/
    int n,t;
    cin>>n>>t;
    vec<vec<int>> g(n,vec<int>(n));
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            if(i==0&&j==n-1)g[j][i]=1;
            g[i][j]=!g[j][i];
        }//cout<<'\n';
        
    }
    //cout<<"01110\n00101\n00010\n01001\n10100\n"<<endl;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout<<g[i][j];
        }cout<<'\n';
        
    }
    cout<<endl;
    while(t--)
    {
        vec<bool> vis(n+1,0);
        bool enc=0;
        dfs(1,n,vis,enc,1);
        cout<<"! ";
        while(!res.empty())
        {
            cout<<res.top()<<" ";
            res.pop();
        }cout<<endl;
    }
    return 0;
}

Test details

Test 1

Subtask:

Verdict: ACCEPTED

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

correct output
(empty)

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

Feedback: Q = 11.000000

Test 2

Subtask: 1

Verdict: ACCEPTED

input
01 4 200 rnd

correct output
(empty)

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

Feedback: Q = 6.380000

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: Too many queries

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