Submission details
Task:Hamilton
Sender:Diego_09
Submission time:2026-04-17 14:51:54 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
subtaskverdictscore
#10
#20
#30
#40
Test results
testverdicttimescoresubtask
#10.01 s0details
#2--01details
#30.88 s02, 3details
#40.01 s04details

Compiler report

input/code.cpp: In function 'bool bfs(long long int)':
input/code.cpp:64:62: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   64 |         if(graph[x].size()==1 and graph[x][0]==s and p.size()==n){
      |                                                      ~~~~~~~~^~~
input/code.cpp: In function 'void set_io(std::string)':
input/code.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         freopen((name+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen((name+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~...

Code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#if defined(__has_include)&&__has_include("custom_h/debugging.h")
#define local_run 1
#include "custom_h\debugging.h"
#else 
#define local_run 0
#endif
// #pragma GCC target ("avx2");
// #pragma GCC optimize ("Ofast");
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end()
#define keyval find_by_order
#define valkey order_of_key
#define int long long
#define pb push_back
#define s second
#define f first

using namespace __gnu_pbds; 
using namespace std;
template<typename T>
using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T>
using omset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
    
void set_io(string name=""){
    ios_base::sync_with_stdio(0);cin.tie(0);
    if(name.size() and !local_run){
        freopen((name+".in").c_str(),"r",stdin);
        freopen((name+".out").c_str(),"w",stdout);
    }
}

const int my[]={0,0,1,-1,1,1,-1,-1};
const int mx[]={1,-1,0,0,1,-1,-1,1};
const int md=1e9+7;
const int oo=1e18;

vector<int>graph[60];
vector<bitset<60>>mat(60);
int n,q;

bool bfs(int s){
    queue<pair<int,pair<bitset<60>,vector<int>>>>q;
    
    bitset<60>aux;
    vector<int>aux2;

    q.push({s,{aux,aux2}});

    while(!q.empty()){
        int x=q.front().f;
        bitset<60>v=q.front().s.f;
        vector<int>p=q.front().s.s;
        q.pop();

        // cerr<<x<<" "<<p<<" "<<"\n";

        v[x]=1;
        p.pb(x);

        if(graph[x].size()==1 and graph[x][0]==s and p.size()==n){
            cout<<"! ";
            for(int i:p)cout<<i<<" ";
            cout<<endl;
            return 1;
        }

        for(int i:graph[x]){
            if(!v[i])q.push({i,{v,p}});
        }
    }
    return 0;
}

void solve(){
    cin>>n>>q;

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(i==1 and j==n)continue;
            mat[i][j]=1;
        }
    }
    mat[n][1]=1;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cout<<mat[i][j];
        }
        cout<<"\n";
    }    
    cout<<flush;

    while(q--){
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                cout<<"? "<<i<<" "<<j<<endl;
                char c;
                cin>>c;

                if(c=='<'){
                    graph[j].pb(i);
                }else{
                    graph[i].pb(j);
                }
            }
        }

        // for(int i=1;i<=n;i++){
        //     cerr<<graph[i]<<"\n";
        // }

        for(int i=1;i<=n;i++){
            if(bfs(i))break;
            // cerr<<"\n";
        }
    }
}

int32_t main(){set_io("");
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
}

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
(empty)

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
111111111111111111111111111111...

Feedback: Self-loop