제출 #992568

#제출 시각아이디문제언어결과실행 시간메모리
992568vqpahmad마술쇼 (APIO24_show)C++17
100 / 100
267 ms195804 KiB
#include<bits/stdc++.h> #include "Alice.h" using namespace std; #ifdef ONPC #include"debug.h" #else #define debug(...) 42 #endif #define ll long long #define pii pair<int,int> #define F first #define S second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } const int mod = 1e9 + 7; const int MAXN = 5000; const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3f; // you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables. // you had better not use the same global variables in function Alice() and in function Bob(). struct DSU { int p[MAXN], s[MAXN]; void init(){ for (int i = 0; i < MAXN; i++){ p[i] = i; s[i] = 1; } } int find(int u){ if (p[u] == u) return u; return p[u] = find(p[u]); } void merge(int u, int v){ u = find(u); v = find(v); if (s[u] < s[v]) swap(u, v); s[u] += s[v]; p[v] = u; return; } } dsu; int edges[MAXN][MAXN]; vector<pair<int,int>> Alice(){ srand(14); for (int i = 0; i < 5000; i++){ for (int j = i + 1; j < 5000; j++){ edges[i][j] = rand() % 60; edges[j][i] = edges[i][j]; } } long long x = setN(5000); vector<pii> ans; dsu.init(); set<int> st; while (sz(ans) < 4999){ int u = rand() % 5000, v = rand() % 5000; bool flag = 1; for (int i = u; i < u + 5000 && flag; i++){ for (int j = v; j < v + 5000 && flag; j++){ int U = i % 5000, V = j % 5000; if (U == V) continue; if (dsu.find(U) != dsu.find(V) && ((x >> edges[U][V]) & 1)){ st.insert(edges[U][V]); dsu.merge(U, V); ans.pb({U, V}); flag = 0; } } } } for (int i = 0; i < sz(ans); i++){ if (ans[i].F > ans[i].S) swap(ans[i].F, ans[i].S); } sort(all(ans)); for (int i = 0; i < sz(ans); i++){ ans[i].F++; ans[i].S++; } return ans; }
#include<bits/stdc++.h> #include "Bob.h" using namespace std; #ifdef ONPC #include"debug.h" #else #define debug(...) 42 #endif #define ll long long #define pii pair<int,int> #define F first #define S second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } const int mod = 1e9 + 7; const int MAXN = 1e6 + 15; const int inf = 0x3f3f3f3f; const ll INF = 0x3f3f3f3f3f3f3f3f; // you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables. // you had better not use the same global variables in function Alice() and in function Bob(). int edges2[5001][5001]; long long Bob(std::vector<std::pair<int,int>> V){ srand(14); for (int i = 0; i < 5000; i++){ for (int j = i + 1; j < 5000; j++){ edges2[i][j] = rand() % 60; } } ll ans = 0; set<int> st; for (auto [u, v] : V){ st.insert(edges2[u - 1][v - 1]); ans |= (1ll << edges2[u - 1][v - 1]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...