#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "../Library/debug.h"
#else
#include "Alice.h"
#define dbg(x...)
#endif
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i)
#define trav(a, x) for (auto& a : x)
#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
const char nl = '\n';
const int INF = 1e9;
const ll MOD = 998244353;
const int mxN = 3e5+5;
struct DSU {
vector<int> par, sz;
int c;
DSU(int n) : par(n), c(n) {
sz.resize(n, 1);
for (int i = 0; i < n; ++i) par[i] = i;
}
int find(int i) {
return par[i] == i ? i : (par[i] = find(par[i]));
}
bool same(int i, int j) {
return find(i) == find(j);
}
int get_size(int i) {
return sz[find(i)];
}
int count() {
return c;
}
int merge(int i, int j) {
if ((i = find(i)) == (j = find(j))) return -1;
else --c;
if (sz[i] > sz[j]) swap(i, j);
par[i] = j;
sz[j] += sz[i];
return j;
}
};
#ifdef DEBUG
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll x2;
ll setN(int n){
x2=uniform_int_distribution<ll>(1,5e3)(rng);
return x2;
}
#endif
DSU dsu(5000);
vpi Alice(){
int n=5000;
ll x=setN(n);
vpi e;
FOR(i,1,n+1){
if(i!=x){
e.pb({i,x});
}
}
return e;
// int n=4982;
// ll x=setN(n);
// vpi e;
// F0R(i,60){
// if((x>>i)&1){
// F0R(j,82){
// e.pb({j*60+i+1,(j+1)*60+i+2});
// }
// }
// }
// trav(i,e){
// if(!~dsu.merge(i.f-1,i.s-1)){
// assert(0==1);
// }
// }
// F0R(i,n-1){
// if(dsu.same(n-1,i)==false){
// dsu.merge(n-1,i);
// e.push_back({n-1,i});
// }
// }
// dbg(sz(e))
// assert(sz(e)==n-1);
// return e;
}
#ifdef DEBUG
ll Bob(vpi e){
vi d(5001);
trav(i,e){
d[i.f]++;
d[i.s]++;
if(d[i.f]>1)
return i.f;
if(d[i.s]>1)
return i.s;
}
// set<pi> st;
// st.insert(all(e));
// ll res=0;
// F0R(i,60){
// F0R(j,82){
// if(st.find({j*60+i+1,(j+1)*60+i+2})!=st.end()){
// res+=(1LL<<i);
// break;
// }
// }
// }
// return res;
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
auto a=Alice();
// shuffle(all(a),rng);
int y=uniform_int_distribution<int>(0,sz(a)/2-1)(rng);
dbg(sz(a));
a.erase(a.end()-y,a.end());
dbg(sz(a));
dbg(x2,Bob(a));
assert(x2==Bob(a));
}
#endif
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "../Library/debug.h"
#else
#include "Bob.h"
#define dbg(x...)
#endif
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i)
#define trav(a, x) for (auto& a : x)
#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
const char nl = '\n';
const int INF = 1e9;
const ll MOD = 998244353;
const int mxN = 3e5+5;
ll Bob(vpi e){
vi d(5001);
trav(i,e){
d[i.f]++;
d[i.s]++;
if(d[i.f]>1)
return i.f;
if(d[i.s]>1)
return i.s;
}
// set<pi> st;
// st.insert(all(e));
// ll res=0;
// F0R(i,60){
// F0R(j,82){
// if(st.find({j*60+i+1,(j+1)*60+i+2})!=st.end()){
// res+=(1LL<<i);
// break;
// }
// }
// }
// return res;
}
#ifdef DEBUG
int32_t main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
#endif
컴파일 시 표준 에러 (stderr) 메시지
# 2번째 컴파일 단계
Bob.cpp: In function 'll Bob(vpi)':
Bob.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
59 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |