Scan to open on your phone
Point a camera at the QR code - it opens this exact paste, no app needed.
https://codepastes.com/zzgrp04zktrk3kgnEggPlain Text
#include<bits/stdc++.h>
#include "grader.h"
#define ll long long
#define ss second
#define ff first
#define pb push_back
using namespace std;
const ll inf=1e18;
const ll mod=998244353;
const int mxn=505;
vector<int> v;
vector<vector<int>> g;
void dfs(int u,int p) {
v.pb(u);
for(int e:g[u]) {
if(e!=p) {
dfs(e,u);
}
}
}
int findEgg(int n,vector<pair<int,int>> bridges) {
g.clear();
g.resize(n+1);
for(auto x:bridges) {
g[x.ff].pb(x.ss);
g[x.ss].pb(x.ff);
}
v.clear();
dfs(1,0);
int l=0,r=n-1;
while(l<r) {
int m=(l+r)/2;
vector<int> q;
for(int i=0; i<=m; i++) {
q.pb(v[i]);
}
int f=query(q);
if(f) {
r=m;
} else {
l=m+1;
}
}
return v[l];
}688 chars · codepastes.com