#include<bits/stdc++.h> using namespace std; const int N = 1e5+5; int n, m, A[N], deg[N], mx2, mx1, sd1; signed main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i=1; i<=n; ++i) cin >> A[i]; for (int i=1; i<=m; ++i) {...
#include<cstdio> #include<iostream> #define RI register int #define CI const int& using namespace std; const int N=100005; int t,n,m,x,y,deg[N]; int main() { for (scanf("%d",&t);t;--t) { scanf("%d%d",&n,&m); for (RI i=1;i<=n;++i) deg[i]=0; for (RI i=...
实现的话用个堆模拟一下即可,总复杂度O(nlogn)O(nlogn) #include<cstdio>#include<iostream>#include<vector>#include<queue>#defineRI register int#defineCI const int definefi first#definese secondusingnamespacestd;typedefpair <int,int> pi;constintN=200005;intt,n,m,p[N],x,y,deg_G[N],...
#include<cstdio> #include<iostream> #define RI register int #define CI const int& using namespace std; const int N=200005; struct edge { int to,nxt; }e[N<<1]; int n,m,cnt,x,y,head[N],deg[N][2],q[N]; bool vis[N]; char s[N]; inline void addedge(CI x,CI y) { ...
#include<cstdio> #include<set> #define RI register int #define CI const int& using namespace std; const int N=100005; struct edge { int to,nxt; }e[N<<2]; int head[N],n,m,x,y,cnt,bel[N],deg[N],ct[N],tot,lim; set <int> s; bool vis[N]; inline void addedge(CI x,...
#include<cstdio> #include<iostream> #define RI register int #define CI const int& #define Tp template <typename T> using namespace std; const int N=1e6+5; int n,x,y,deg[N]; class FileInputOutput { private: static const int S=1<<21; #define tc() (A==B&&(B=(A=Fin)+frea...
#include <bits/stdc++.h> std::vector <int> G[300005]; int deg[300005]; void work() { int n; std::cin >> n; std::vector<int> pa(n, 0); std::vector<std::vector<int>> ch(n), loop(n); std::vector<int> dfn(n), dep(n); for(int i = 1; i < n; ++i) std::...
const int& using namespace std; typedef pair <int,int> pi; const int N=50005,INF=1e18; int n,m1,m2,s,x[N],y[N],z[N],fa[N],rst[N],idx,bel[N],deg[N],dis[N],vis[N]; vector <pi> G1[N],G2[N]; vector <int> pnt[N]; inline int getfa(CI x) { return fa[x]...
push_back(bel[j]),++deg[bel[j]]; for (i=1;i<=scc;++i) if (!deg[i]) { for (auto x:num[i]) if (val[x]) add(x>>2); for (auto x:num[i]) ans[x]=ret; for (auto to:nv[i]) DFS(to); for (auto x:num[i]) if (val[x]) del(x>>2); } for (scanf("%d",...