183862025-10-21 14:58:10ubormaciTaláld ki a permutációt!cpp17Time limit exceeded 0/1001ms748 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
#include <cstdint>
#include <bitset>
using namespace std;

typedef int32_t ll;

ll ask(ll i, ll j) {
    cout << i << " " << j << "\n";
	cout.flush();
	ll x;
	cin >> x;
    
    if(x == -100) {
        exit(0);
    }

    return x;
}


vector<ll> solve(ll size) {
    ll n = size;

    vector<bitset<12>> v(n+1, bitset<12>(0));

    /*
    v[0][1] = 1;
    cerr << v[0] << "\n";
    for(ll i = 0; i < v[0].size(); i++) {
        cout << v[0][i];
    }
    return vector<int>(n, 0);
    */

    vector<ll> out(n+1, 0);

    vector<ll> largestbit(n+1, 0);

    vector<ll> characteristic(11, 0);

    // we can match each index with itself to get its highest bit
    
    ll hg = 0;

    for(ll i = 1; i <= n; i++) {
        //cerr << "\ni=" << i;
        ll curr = ask(i, i);
        //cerr << "\ncurr=" << curr;
        v[i][curr] = 1;
        largestbit[i] = curr;
        hg = max(hg, curr);
        characteristic[curr] = i;
    }
    
    //cerr << "\nhg=" << hg;

    for(ll i = 0; i < hg; i++) {
        //cerr << "\ni=" << i;
        ll base = characteristic[i];
        if(base == 0) {
            continue;
        }
        //cerr << "\ncharacteristic=" << base;
        for(ll j = 1; j <= n; j++) {
            //cerr << "\nj=" << j;
            if(largestbit[j] <= largestbit[base]) {
                //cerr << "\nlargest bit of j is smaller or equal to base's";
                continue;
            }

            ll iscurr = ask(base, j);
            //cerr << "\niscurr(base,j)=" << iscurr;
            if(iscurr == i) {
                v[j][i] = 1;
            }
        }
    }

    vector<ll> twopows(12, 0);
    ll r = 1;
    for(ll i = 0; i < 12; i++) {
        twopows[i] = r;
        r *= 2;
    }

    //cerr << twopows;

    for(ll i = 1; i <= n; i++) {
        for(ll j = 0; j < v[i].size(); j++) {
            out[i] += twopows[j] * v[i][j];
        }
    }

    return out;

}


int main() {

    setvbuf(stdout, NULL, _IONBF, 0);
    setvbuf(stderr, NULL, _IONBF, 0);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;
    
    vector<ll> v = solve(n);
    cout << "! ";
    for(ll i = 1; i <= n; i++) {
        cout << v[i];
        if(i < n) {
            cout << " ";
        }
    }
    cout.flush();
    exit(0);
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Time limit exceeded1ms316 KiB
subtask20/5
2Time limit exceeded1ms572 KiB
subtask30/5
3Time limit exceeded1ms564 KiB
subtask40/5
4Time limit exceeded1ms568 KiB
subtask50/5
5Time limit exceeded1ms576 KiB
subtask60/5
6Time limit exceeded1ms568 KiB
subtask70/5
7Time limit exceeded1ms564 KiB
subtask80/5
8Time limit exceeded1ms316 KiB
subtask90/5
9Time limit exceeded1ms564 KiB
subtask100/5
10Time limit exceeded1ms316 KiB
subtask110/5
11Time limit exceeded1ms316 KiB
subtask120/5
12Time limit exceeded1ms564 KiB
subtask130/5
13Time limit exceeded1ms564 KiB
subtask140/5
14Time limit exceeded1ms748 KiB
subtask150/5
15Time limit exceeded1ms564 KiB
subtask160/5
16Time limit exceeded1ms564 KiB
subtask170/5
17Time limit exceeded1ms564 KiB
subtask180/5
18Time limit exceeded1ms564 KiB
subtask190/5
19Time limit exceeded1ms564 KiB
subtask200/5
20Time limit exceeded1ms564 KiB
subtask210/5
21Time limit exceeded1ms564 KiB