Submission #953305

#TimeUsernameProblemLanguageResultExecution timeMemory
953305jmyszka2007Chameleon's Love (JOI20_chameleon)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <fstream> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> using namespace __gnu_pbds; using namespace std; template<class A, class B> ostream& operator<<(ostream& o, const pair<A, B>& p) {return o << '(' << p.first << ", " << p.second << ')';} template<size_t Index = 0, typename... Types> ostream& printTupleElements(ostream& o, const tuple<Types...>& t) {if constexpr (Index < sizeof...(Types)){if(Index > 0){o << ", ";}o << get<Index>(t);printTupleElements<Index + 1>(o, t);}return o;} template<typename... Types> ostream& operator<<(ostream& o, const tuple<Types...>& t){o << "(";printTupleElements(o, t);return o << ")";} template<class T> auto operator<<(ostream& o, const T& x) -> decltype(x.end(), o){o << '{';bool first = true;for (const auto& e : x){if (!first){o << ", ";}o << e;first = false;} return o << '}';} struct custom_hash {static uint64_t splitmix64(uint64_t x) {x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;return x ^ (x >> 31);} size_t operator()(uint64_t x) const {static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();return splitmix64(x + FIXED_RANDOM);}}; //#define DEBUG #ifdef DEBUG #define fastio() #define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n' #else #define fastio() ios_base::sync_with_stdio(0); cin.tie(0); #define debug(...) #endif typedef long long ll; typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; #define pi pair<int, int> #define pll pair<ll, ll> #define st first #define nd second #define vi vector<int> #define vll vector<ll> #define eb emplace_back #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() void solve() { //ifstream cin("nazwa.in"); //ofstream cout("nazwa.out"); int n; cin >> n; //vi plec(2 * n + 1), val(2 * n + 1), to(2 * n + 1); //for(int i = 1; i <= 2 * n; i++) { //cin >> plec[i]; //} //for(int i = 1; i <= 2 * n; i++) { //cin >> val[i]; //} //for(int i = 1; i <= 2 * n; i++) { //cin >> to[i]; //} vector<vi>g(2 * n + 1); vector<set<int> >kt(2 * n + 1); vi L, R; int ans = 0; auto ile = [&](vi A, int x) { A.eb(x); cout << "? " << sz(A) << ' '; for(auto y : A) { cout << y << ' '; } cout << endl; int a; cin >> a; return a; //set<int>nA; //for(auto y : A) { //nA.insert(y); //} //assert(sz(nA) == sz(A)); //set<int>jak; //for(auto y : A) { //if(nA.find(to[y]) != nA.end()) { //jak.insert(val[to[y]]); //} //else { //jak.insert(val[y]); //} //} //ans++; //return sz(jak); }; for(int i = 1; i <= 2 * n; i++) { int r2 = 0; debug(L, R); while(r2 < sz(L)) { vi tmp = {L.begin() + r2, L.end()}; if(ile(tmp, i) < sz(tmp) + 1) { int l = r2, r = sz(L) - 1; while(l < r) { debug(l, r); int mid = (l + r) / 2; tmp = {L.begin() + r2, L.begin() + mid + 1}; if(ile(tmp, i) < sz(tmp) + 1) { r = mid; } else { l = mid + 1; } } g[i].eb(L[r]); g[L[r]].eb(i); kt[i].insert(L[r]); kt[L[r]].insert(i); r2 = r + 1; } else { break; } } r2 = 0; while(r2 < sz(R)) { vi tmp = {R.begin() + r2, R.end()}; if(ile(tmp, i) < sz(tmp) + 1) { int l = r2, r = sz(R) - 1; while(l < r) { debug(l, r); int mid = (l + r) / 2; tmp = {R.begin() + r2, R.begin() + mid + 1}; if(ile(tmp, i) < sz(tmp) + 1) { r = mid; } else { l = mid + 1; } } g[i].eb(R[r]); g[R[r]].eb(i); kt[i].insert(R[r]); kt[R[r]].insert(i); r2 = r + 1; } else { break; } } L.clear(), R.clear(); vi kol(i + 1, -1); auto dfs = [&](auto &&dfs, int v, int k) -> void { kol[v] = k; if(!kol[v]) { L.eb(v); } else { R.eb(v); } for(auto x : g[v]) { if(kol[x] == -1) { kol[x] = !k; dfs(dfs, x, kol[x]); } } }; for(int j = 1; j <= i; j++) { if(kol[j] == -1) { dfs(dfs, j, 0); } } } for(int x = 1; x <= 2 * n; x++) { gp_hash_table<int, int, custom_hash>cnt; for(auto y : g[x]) { for(auto z : g[x]) { if(y < z) { //debug(y, z); if(ile({y, z}, x) == 2) { cnt[y]++; cnt[z]++; } } } } //debug(g[x], cnt); for(auto [v, a] : cnt) { if(a == 2) { kt[v].erase(x); kt[x].erase(v); } } } debug(ans); assert(ans <= 20'000); for(auto x : L) { cout << "! " << x << ' ' << *(kt[x].begin()) << endl; //assert(val[x] == val[*(kt[x].begin())]); } } int main() { fastio(); int t = 1; //cin >> t; while(t--) { solve(); } }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccfzYMrO.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccb8mW2N.o:chameleon.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccfzYMrO.o: in function `main':
grader.cpp:(.text.startup+0x1b9): undefined reference to `Solve(int)'
collect2: error: ld returned 1 exit status