Submission details
Task:Hamilton
Sender:Juan_Alejandro
Submission time:2026-04-17 11:26:19 +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.03 s02, 3details
#40.32 s04details

Compiler report

input/code.cpp: In function 'void dfs(long long int, std::vector<std::vector<long long int> >&, std::vector<bool>&, std::vector<bool>&, long long int, bool&)':
input/code.cpp:22:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int v=1;v<x.size();v++)
      |                 ~^~~~~~~~~
input/code.cpp:38:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int v=1;v<x.size();v++)
      |                 ~^~~~~~~~~
input/code.cpp:51:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     if(c==x.size()-1-1&&query(u,1))
      |        ~^~~~~~~~~~...

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,vec<vec<int>> &x,vec<bool> &vis,vec<bool> &viss2,int d,bool &enc)
{
    if(!d)
    vis[u]=1;else
    viss2[u]=1;
    int allv=x.size();
    for(int v=1;v<x.size();v++)
    {
        if(vis[v])allv--;
        if((!vis[v])&&query(u,v))
        {
            dfs(v,x,vis,viss2,0,enc);
            if(enc)
            {
                res.push(u);
                return;
            }
        }
    }
    allv=!allv;
    int c=0;
    if(allv)
    for(int v=1;v<x.size();v++)
    {
        if(viss2[v])c++;
        if(v!=1&&(!viss2[v])&&query(u,v))
        {
            dfs(v,x,vis,viss2,1,enc);
            if(enc)
            {
                res.push(u);
                return;
            }
        }
    }
    if(c==x.size()-1-1&&query(u,1))
    {
        enc=1;
        res.push(1);
        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<<endl;
        
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout<<g[i][j];
        }cout<<endl;
        
    }
    cout<<endl;
    while(t--)
    {
        vec<bool> vis(n+1,0);
        vec<bool> viss2(n+1,0);
        bool enc=0;
        dfs(1,g,vis,viss2,0,enc);
        cout<<"! ";
        while(!res.empty())
        {
            cout<<res.top()<<" ";
            res.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
01110
00111
00011
...

Feedback: Formatting error

Test 2

Subtask: 1

Verdict:

input
01 4 200 rnd

correct output
(empty)

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

Feedback: Formatting error

Test 3

Subtask: 2, 3

Verdict:

input
02 50 200 rnd

correct output
(empty)

user output
Activating encoder mode
50 200
011111111111111111111111111111...

Feedback: Formatting error

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