Submission details
Task:Hamilton
Sender:jsesok
Submission time:2026-08-25 14:55:59 +0300
Language:C++ (C++23)
Status:READY
Result:0
Feedback
subtaskverdictscore
#10
#20
#30
#40
Test results
testverdicttimescoresubtask
#10.01 s0details
#20.01 s01details
#30.01 s02, 3details
#40.04 s04details

Code

#include <iostream>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
  /*  ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(0);*/
    int n, t, s, sum, in;
    char c;
    cin>>n>>t;
    vector<vector<int>> a(n, vector<int> (n, 0));
    for (int i=0; i<n; ++i)
    {
        for (int j=1; j<=10-i%10; ++j)
            a[i][(i+j)%n]=1;
    }
    for (int i=0; i<n; ++i)
    {
        for (int j=0; j<n; ++j)
            cout<<a[i][j];
        cout<<endl;
    }
    for (int i=0; i<t; ++i)
    {
        vector<vector<int>> g(n, vector<int> (n, -1));
        vector<int> put, p(n, 0), v;
        vector<pair<int, int>> kol;
        in=0;
        s=0;
        while (s!=n)
        {
            s+=1;
            p[in]=1;
            put.push_back(i);
            if (s==n)
                break;
            v={};
            kol={};
            for (int j=0; j<n; ++j)
            {
                if (in==j || g[in][j]!=-1 || p[j]==1)
                    continue;
                cout<<"? "<<in+1<<" "<<j+1<<endl;
                cin>>c;
                if (c=='>')
                {
                    v.push_back(j);
                    g[in][j]=1;
                    g[j][in]=0;
                }
                else
                {
                    g[in][j]=0;
                    g[j][in]=1;
                }
            }
            for (int i : put)
            {
                s+=1;
                sum=0;
                for (int j : put)
                {
                    if (i==j)
                        continue;
                    if (g[i][j]==-1)
                    {
                        cout<<"? "<<i+1<<" "<<j+1<<endl;
                        cin>>c;
                        if (c=='>')
                        {
                            g[i][j]=1;
                            g[j][i]=0;
                            sum+=1;
                        }
                        else
                        {
                            g[i][j]=0;
                            g[j][i]=1;
                        }
                    }
                    else if (g[i][j]==1)
                        sum+=1;
                }
                kol.push_back({sum, i});
            }
            sort(kol.begin(), kol.end());
            for (int i=0; i<(int) kol.size()-1; ++i)
            {
                p[kol[i].second]=1;
                put.push_back(kol[i].second);
            }
            in=kol.back().second;
            s-=1;
        }
        cout<<"!";
        for (int i=0; i<n; ++i)
            cout<<" "<<put[i]+1;
        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
11111
11111
11111
...

Feedback: Self-loop

Test 2

Subtask: 1

Verdict:

input
01 4 200 rnd

correct output
(empty)

user output
Activating encoder mode
4 200
1111
1111
1111
...

Feedback: Self-loop

Test 3

Subtask: 2, 3

Verdict:

input
02 50 200 rnd

correct output
(empty)

user output
Activating encoder mode
50 200
011111111110000000000000000000...

Feedback: Duplicate or missing edge in given graph

Test 4

Subtask: 4

Verdict:

input
03 500 200 rnd

correct output
(empty)

user output
Activating encoder mode
500 200
011111111110000000000000000000...

Feedback: Duplicate or missing edge in given graph