Submission #826200

# Submission time Handle Problem Language Result Execution time Memory
826200 2023-08-15T11:09:18 Z themm1 ICC (CEOI16_icc) C++17
0 / 100
2 ms 468 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
// ordered set whith s.order_of_key(x) method, which returns rank of element x in set s
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
*/

// pair printing
template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {out << "(" << par.first << "; " << par.second << ")"; return out;}
// set printing
template <class T>
ostream& operator<<(ostream& out, const set<T> &cont) { out << "{"; for(const auto &x:cont) out << x << ", "; out << "}"; return out; }
// map printing
template <class T, class U>
ostream& operator<<(ostream& out, const map<T, U> &cont) {out << "{"; for(const auto &x:cont) out << x << ", "; out << "}"; return out; }
// unordered_set printing
template <class T>
ostream& operator<<(ostream& out, const unordered_set<T> &cont) {out << "{";for(const auto &x:cont) out << x << ", ";out << "}";return out;}
// unordered_map printing
template <class T, class U>
ostream& operator<<(ostream& out, const unordered_map<T, U> &cont) {out << "{";for(const auto &x:cont) out << x << ", ";out << "}";return out;}
// vector printing
template<class T>
ostream& operator<<(ostream& out, const vector<T> &cont){ out << "[";  for (const auto &x:cont) out << x << ", ";  out << "]"; return out;}

#define print(x) cout << (x) << endl;
#define dmp(x) cerr << #x << " = " << x << endl
#define dmpn(x) cerr << #x << " = " << x << "; "
#define dmpl(x) cerr << "Line " << __LINE__ << ": " << #x << " = " << x << endl

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define pb push_back
#define ff first
#define ss second
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define contains(s,x) ((s).find(x) != (s).end())
const int MOD = 998244353;

int N;
int U = 1, V = 15;
map<int, vector<bitset<32>>> components;

bool my_query(int a_sz, int b_sz, vector<int> &a, vector<int> &b) {
        // dmpn(a); dmp(b);
        if (find(all(a), U) != end(a) && find(all(b), V) != end(b)) return true;
        if (find(all(a), V) != end(a) && find(all(b), U) != end(b)) return true;
        return false;
}

pair<vector<int>, vector<int>> split(int j) {
        pair<vector<int>, vector<int>> p;
        for (int i = 1; i <= N; i++) if (!components[i].empty()) {
                if (bitset<32>(i)[j]) p.ff.pb(i);
                else p.ss.pb(i);
        }
        return p;
}

void run(int n) {
        N = n;
	int K = 32 - __builtin_clz(N);
	for (int i = 1; i <= N; i++) components[i].pb(i);

	for (int _ = 0; _ < 1; _++) {
		bitset<32> xr; 
		for (int i = 0; i < K; i++) {
                        auto p = split(i);
			// bool ans = my_query(sz(p.ff), sz(p.ss), p.ff, p.ss);
			bool ans = query(sz(p.ff), sz(p.ss), p.ff.data(), p.ss.data());
			xr[i] = ans;
		}
                vector<int> xri, xrj, full_xri;
                for (int i = 1; i <= N; i++) if (!components[i].empty()) {
                        int j = i ^ xr.to_ulong();
                        if (components[j].empty() || j > i) continue;
                        xri.pb(i);
                        xrj.pb(j);
                        for (bitset<32> a : components[i]) full_xri.pb(int(a.to_ulong()));
                }
                // dmp(xri); dmp(xrj);
                int l = 0, r = sz(full_xri) - 1;
                while (l < r) {
                        int mid = (l + r) / 2;
                        vector<int> left(begin(full_xri) + l, begin(full_xri) + mid + 1);
                        bool ans = query(sz(left), sz(xrj), left.data(), xrj.data());
                        if (ans) r = mid;
                        else l = mid + 1;
                        // dmpn(l); dmp(r);
                }
                int a = full_xri[l];
                vector<int> v_a = { a };
                vector<int> comp;
                for (auto b : components[a ^ xr.to_ulong()]) comp.pb(int(b.to_ulong()));
                l = 0, r = sz(comp) - 1;
                while (l < r) {
                        int mid = (l + r) / 2;
                        vector<int> left(begin(comp) + l, begin(comp) + mid + 1);
                        bool ans = query(sz(comp), 1, comp.data(), v_a.data());
                        if (ans) r = mid;
                        else l = mid + 1;
                }
                int b = comp[l];
                cout << a << " " << b << endl;
                for (auto x : components[b]) components[a].pb(x);
                components[b].clear();
                setRoad(a, b);
	}
}

/*
int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);

        int t = 1;
        run(15);
        // cin >> t;
        while (t--) {
                // solve();
        }
}
*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Program is not terminated properly.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 432 KB Program is not terminated properly.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Program is not terminated properly.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Program is not terminated properly.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Program is not terminated properly.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 424 KB Program is not terminated properly.
2 Halted 0 ms 0 KB -