183572025-10-21 13:52:17ubormaciTaláld ki a permutációt!cpp17Forditási hiba
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <array>
#include <string>
#include <cstdio>
#include <iterator>
#include <unordered_set>
#include <cstdint>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <fstream>
#include <bitset>
#include "find-the-permutation.h"
using namespace std;

#pragma GCC optimize("O2")

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

/*

notes:

int64_t
stoi(string s) -> string to int
to_string() -> int (or else) to string

vector declaration:
vector<ll> v(n, 0)
vector<vector<ll>> v(n, vector<ll>(n, 0));

{if statement} ? {truth value} : {false value}

set lower bound/upper bound:
 	// . . . m1 . . . d . . . . m2
    auto m1_it = b.lower_bound(d);
    advance(m1_it, -1);
    m1 = *m1_it;
	m2 = *b.upper_bound(d);

#ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif

constexpr auto lcm(auto x, auto... xs)
{
	return ((x = std::lcm(x, xs)), ...);
}

std::gcd(int a, int b)

*/

typedef long long ll;

/*
int ask(int i, int j) {
    // example: 4 3 2 1 5
    vector<bitset<4>> v(6, 0);
    v[1] = 4;
    v[2] = 3;
    v[3] = 2;
    v[4] = 1;
    v[5] = 5;

    bitset<4> result = v[i] & v[j];
    for(ll i = 3; i > -1; i--) {
        if(result[i] == 1) {
            return i;
        }
    }

    return -1;
}
*/

vector<int> solve(int N) {
    ll n = N;

    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<int> 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];
        //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() {
    cout << solve(5);
}
*/
Forditási hiba
open /var/local/lib/isolate/411/box/a.out: no such file or directory
main.cpp:19:10: fatal error: find-the-permutation.h: No such file or directory
   19 | #include "find-the-permutation.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.