#include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; #define ll long long #define INF 1000000000000000000 using std::cout; using std::endl; using std::chrono::duration_cast; using std::chrono::milliseconds; using std::chrono::seconds; using std::chrono::system_clock; //namespace atcoder { ostream& operator<<(ostream& os,vector& a){ for(int i:a){ os< ans(200010,-1); struct _edge { int to, rev; ll cap; int index; }; template struct mf_graph { public: mf_graph() : _n(0) {} mf_graph(int n) : _n(n), g(n) {} int add_edge(int from, int to, Cap cap,int index) { assert(0 <= from && from < _n); assert(0 <= to && to < _n); assert(0 <= cap); int m = int(pos.size()); pos.push_back({from, int(g[from].size())}); int from_id = int(g[from].size()); int to_id = int(g[to].size()); if (from == to) to_id++; g[from].push_back(_edge{to, to_id, cap, index}); g[to].push_back(_edge{from, from_id, 0, index}); return m; } struct edge { int from, to; Cap cap, flow; }; edge get_edge(int i) { int m = int(pos.size()); assert(0 <= i && i < m); auto _e = g[pos[i].first][pos[i].second]; auto _re = g[_e.to][_e.rev]; return edge{pos[i].first, _e.to, _e.cap + _re.cap, _re.cap}; } Cap flow(int s, int t) { return flow(s, t, std::numeric_limits::max()); } Cap flow(int s, int t, Cap flow_limit) { assert(0 <= s && s < _n); assert(0 <= t && t < _n); assert(s != t); std::vector level(_n), iter(_n); internal::simple_queue que; auto bfs = [&]() { std::fill(level.begin(), level.end(), -1); level[s] = 0; que.clear(); que.push(s); while (!que.empty()) { int v = que.front(); que.pop(); for (auto e : g[v]) { if (e.cap == 0 || level[e.to] >= 0) continue; level[e.to] = level[v] + 1; if (e.to == t) return; que.push(e.to); } } }; auto dfs = [&](auto self, int v, Cap up) { if (v == s) return up; Cap res = 0; int level_v = level[v]; for (int& i = iter[v]; i < int(g[v].size()); i++) { //cout<<"i:"<> pos; std::vector> g; }; ostream& operator<<(ostream& os,const _edge& a){ return os<(system_clock::now().time_since_epoch()).count(); ll N,A,B; cin>>N; //Dinic F(200002); //Dinic F; //cout<<"INF:"< F(2*N+2); for(int i=0;i>A>>B; A--;B--; /* F.add_edge(200000,i,1); F.add_edge(i,100000+A,1); if(A!=B)F.add_edge(i,100000+B,1); F.add_edge(100000+i,200001,1); */ F.add_edge(2*N,i,1,-1); F.add_edge(i,N+A,1,i); if(A!=B)F.add_edge(i,N+B,1,i); F.add_edge(N+i,2*N+1,1,-1); } //cerr<<"edge added\n"; //ll cnt=F.max_flow(200000,200001); ll cnt=F.flow(2*N,2*N+1); //cout<(system_clock::now().time_since_epoch()).count(); cerr<