solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
#include <bits/stdc++.h> using namespace std; template <typename TH> void _dbg(const char* sdbg, TH h) { cerr << sdbg << "=" << h << "\n"; } template <typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) { while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, t...); } ...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, s, t, ans, a[N]; int p[N], fa[N]; pair<int, int> b[N]; int get(int x) { return x == fa[x] ? x : fa[x] = get(fa[x]); } bool vis[N]; vector<int> c[N]; void dfs(int x) { vis[x] = 1; c[t].push_back(x); if (!vis[p[x]]) dfs(p[x]); } int main() {...
11
CPP
#include <bits/stdc++.h> using namespace std; vector<int> new_val; inline int Val(int first) { return lower_bound(new_val.begin(), new_val.end(), first) - new_val.begin(); } void Move(vector<int> &ind, vector<int> &a) { int last = a[ind.back()]; for (int i : ind) { swap(a[i], last); } } int n, s; void Dfs(v...
11
CPP
#include <bits/stdc++.h> using namespace std; const int mxN = 2e5; int n, s, a[mxN]; map<int, int> mp1; map<int, vector<int>> mp2; vector<vector<int>> ans; void dfs(int u) { while (!mp2[u].empty()) { int i = mp2[u].back(); mp2[u].pop_back(); dfs(a[i]); ans.back().push_back(i); } mp2.erase(u); } in...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, s; int a[200100]; int sorted[200100]; int been[200100]; map<int, list<int>> alive; list<list<int>> sol; void dfs(int val) { if (alive[val].empty()) return; int k = alive[val].front(); alive[val].pop_front(); been[k] = true; dfs(a[k]); sol.back().push_fron...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, m, f[N], to[N]; pair<int, int> a[N]; bool done[N]; int find(int x) { while (x != f[x]) { x = f[x] = f[f[x]]; } return x; } int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i].first); a[i].s...
11
CPP
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + c - '0'; c = getchar(); } return x * f; } int n, m, len, a[20...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 2; int a[N], p[N], head[N], now = 0; pair<int, int> b[N]; vector<int> cycle[N]; int findd(int x) { if (head[x] < 0) { return x; } return head[x] = findd(head[x]); } void unionn(int x, int y) { x = findd(x), y = findd(y); head[x] += head[y];...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int a[N], b[N], c[N], d[N], e[N]; using VI = vector<int>; VI v[N], rep[N]; int rn; void search(int u) { for (int U; !v[u].empty();) { U = v[u].back(); v[u].pop_back(); search(a[U]); rep[rn].push_back(U); } } int main() { int n, ...
11
CPP
#include <bits/stdc++.h> using namespace std; const int module = 1000000007; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; vector<set<int>> to(n, set<int>()); vector<pair<int, int>> edges(m); vector<int> nbr(n); for (int i = 0; i < m; ++i) { ...
11
CPP
#include <bits/stdc++.h> #pragma GCC optimize(3, "Ofast", "inline") using namespace std; const long long maxn = (long long)1e6 + 5; const long long mod = (long long)998244353; const long long inf = 0x3f3f3f3f3f3f3f3f; pair<long long, long long> a[maxn]; long long in[maxn]; vector<long long> v[maxn]; bool vis[maxn]; lon...
11
CPP
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long N = 3e5 + 10; long long x[N], y[N], deg[N]; vector<long long> vp[N]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, m, k; cin >> n >> m >> k; for (long long i = 1; i <= m; i++) { cin >...
11
CPP
#include <bits/stdc++.h> using namespace std; set<int> se[200100]; int u[200100]; int v[200100]; int vis[200100]; int n, m, k, ans; int num[200100]; void dfs(int st) { if (se[st].size() >= k || vis[st]) return; vis[st] = 1; --ans; for (auto &t : se[st]) { se[t].erase(st); dfs(t); } se[st].clear(); }...
11
CPP
#include <bits/stdc++.h> using namespace std; inline int read() { int sum = 0, ff = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') ff = -1; ch = getchar(); } while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar(); return sum * ff; } const int mod = 1e9 + 7; const int mo = 9982...
11
CPP
#include <bits/stdc++.h> using namespace std; const int maxn = 200100; struct node { int v, u; } e[maxn + 10]; set<int> s[maxn]; int k, ans, in[maxn], vis[maxn], ret[maxn], n, m; queue<int> q; void dele(int x) { set<int>::iterator iter; int u, v; if (vis[x] || in[x] >= k) return; vis[x] = 1; q.push(x); --...
11
CPP
#include <bits/stdc++.h> using namespace std; const int mx = 200 * 1000 + 5; vector<set<int> > vec(mx); int arr1[mx], arr2[mx]; int main() { int i, j, k, n, m, x, y, p, q, l; scanf("%d %d %d", &n, &m, &k); int ans = 0; for (i = 0; i < m; i++) { scanf("%d %d", &x, &y); arr1[i] = x; arr2[i] = y; v...
11
CPP
#include <bits/stdc++.h> const int ms = 200200; int n, m, k; int ans[ms]; std::pair<int, int> edges[ms]; std::vector<int> use[ms]; int deg[ms]; bool del[ms]; int main() { std::cin >> n >> m >> k; for (int i = 0; i < m; i++) { int u, v; scanf("%d %d", &u, &v); use[u].push_back(i); use[v].push_back(i)...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100; vector<pair<int, int>> g[N]; vector<int> deg, ans; vector<pair<int, int>> edge; set<pair<int, int>> good; vector<bool> in_good; void f(int k, int iteration) { while (!good.empty() && good.begin()->first < k) { int v = good.begin()->second; ...
11
CPP
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double pi = acos(-1.0); const int maxn = 200000 + 10; const int mod = 1e9 + 7; inline char _getchar() { static const int BUFSIZE = 100001; static char buf[BUFSIZE]; static char *psta = buf, ...
11
CPP
#include <bits/stdc++.h> using namespace std; using namespace std; int deg[200100]; set<pair<int, int> > pset; vector<pair<int, int> > query; set<int> conn[200100]; bool is_going(int u) { return (pset.find(make_pair(deg[u], u)) != pset.end()); } int n, m, k; void delete_adjacent(int u) { for (auto v : conn[u]) { ...
11
CPP
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const long long INFL = 9223372036854775807LL; const double EPSILON = 0.00000001; const long long MOD = 1000000007; vector<int> adj[200000 + 5]; unordered_map<int, int> removed[200000 + 5]; int degree[200000 + 5]; bool node_removed[200000 + 5]; in...
11
CPP
#include <bits/stdc++.h> int n, m, k, u[200010], v[200010], t[200010]; std::set<int> next[200010], p; inline void remove(int x) { if ((int)next[x].size() < k && p.erase(x)) { for (auto y : next[x]) { next[y].erase(x); remove(y); } next[x].clear(); } } int main() { scanf("%d%d%d", &n, &m, &...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, m, k; set<int> M[200005]; int siz[200005], a[200005], b[200005], dele[200005], cnt, ans[200005]; void check(int u) { if (siz[u] >= k || dele[u]) return; cnt--; dele[u] = 1; queue<int> Q; Q.push(u); while (!Q.empty()) { int ty = Q.front(); Q.pop();...
11
CPP
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int du[maxn]; set<int> g[maxn]; int b1[maxn], b2[maxn], ans[maxn], vis[maxn]; int main() { int n, m, k; scanf("%d%d%d", &n, &m, &k); set<pair<int, int> > s; for (int i = 0; i < m; i++) { int x, y; scanf("%d%d", &x, &y); b1[i] =...
11
CPP
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; template <typename T, typename T2> inline void _max(T &a, T2 b) { a = max((T)a, (T)b); } template <typename T, typename T2> inline void _min(T &a, T2 b) { a = min((T)a, (T)b); } const int MAX = 2e5 +...
11
CPP
#include <bits/stdc++.h> using namespace std; const int mx = 2e5 + 10, cut = 700; int n, m, k, cnt[mx], lv, x[mx], y[mx], dead[mx]; vector<pair<int, int> > adj[mx]; vector<int> res; void er(int a, int b) { auto it = lower_bound(adj[a].begin(), adj[a].end(), make_pair(b, 0)); if (it->second) return; it->second = 1...
11
CPP
#include <bits/stdc++.h> using namespace std; vector<vector<long long> > adj; set<long long> st; vector<long long> deg; long long k; set<pair<long long, long long> > edges; void remove(long long r) { st.erase(r); for (long long i = 0; i < adj[r].size(); i++) { long long c = adj[r][i]; if (st.find(c) == st.e...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, m, k; bool vis[N]; queue<int> Q; set<int> G[N]; vector<int> E[N]; int a[N], b[N], ans[N], sum; void solve() { while (!Q.empty()) { int u = Q.front(); Q.pop(); for (auto v : G[u]) { G[v].erase(u); if (!vis[v] && G[v].s...
11
CPP
#include <bits/stdc++.h> using namespace std; int main(int agrc, char* argv[]) { int n, m, k; scanf("%d %d %d", &n, &m, &k); std::vector<std::vector<int>> edges(n + 1); int selected[n]; for (int i = 0; i < n; ++i) { selected[i] = 1; } int total = n; int friends[m][2]; for (int i = 0; i < m; ++i) {...
11
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cout << fixed << setprecision(15); const int LIM = 600; int N, M, K; cin >> N >> M >> K; vector<int> x(M), y(M); vector<vector<int> > g(N); for (int i = 0; i < M; i++) { cin >> x[i...
11
CPP
#include <bits/stdc++.h> #pragma GCC optimize(3, "Ofast", "inline") using namespace std; bool Finish_read; template <class T> inline void read(T &x) { Finish_read = 0; x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; if (ch == EOF) return; ch = getchar(); } ...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, m, k, numOn, res[200000]; set<int> f[200000]; bool on[200000]; vector<pair<int, int> > v; queue<int> toRemove; void update() { while (!toRemove.empty()) { int r = toRemove.front(); toRemove.pop(); numOn--; for (auto next : f[r]) { f[next].eras...
11
CPP
#include <bits/stdc++.h> using namespace std; const long long N = 5e5; const long long INF = 1e18; const long long mod = 1e9 + 7; set<long long> g[N], st; long long i, j, n, m, k, ans[N], u[N], v[N]; void dfs(long long x) { auto it = st.lower_bound(x); if (*it != x || g[x].size() >= k) return; st.erase(it); for...
11
CPP
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T& x) { char c = getchar(); bool f = false; for (x = 0; !isdigit(c); c = getchar()) { if (c == '-') { f = true; } } for (; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; } if (f) { x = -x; } } ...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; vector<pair<int, int>> edges, g[N]; vector<int> ans; set<pair<int, int>> s; set<int> deleted; int n, m, k, a, b, deg[N]; int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < m; ++i) { scanf("%d%d", &a, &b); edges.emplace_back(a, ...
11
CPP
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long N = 3e5 + 10; long long x[N], y[N], deg[N]; vector<long long> vp[N]; long long removed[N]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, m, k; cin >> n >> m >> k; for (long long i = 1; i ...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, k; int res; vector<set<int>> g; vector<int> used; vector<int> selected; void bfs(int start) { vector<int> seen = {start}; queue<int> q; used[start] = 1; q.push(start); while (!q.empty()) { int v = q.front(); q.pop(); assert(selected[v]); ass...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int n, m, k, deg[N], ans[N]; pair<int, int> edges[N]; set<int> adj[N]; set<pair<int, int> > st; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for (int i = 1; i <= m; i++) { int x, y; cin >> x...
11
CPP
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 2e5 + 10; pair<int, int> edge[maxn]; map<pair<int, int>, int> mp; vector<int> g[maxn]; int vis[maxn]; queue<int> q; int du[maxn]; int ans[maxn]; int main() { std::ios::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; ...
11
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; vector<vector<pair<int, int>>> g(n); vector<int> from(m), to(m); for (int i = 0; i < m; i++) { cin >> from[i] >> to[i]; from[i]--; to[i]--; g[from[i]].emplac...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = int(200000) + 5; int t, n, m, q, k, cnt, sum, x, y, l, r; int a[N], b[N], ans[N]; pair<int, int> edge[N]; vector<pair<int, int> > v[N]; set<pair<int, int> > s; set<pair<int, int> >::iterator it; void update(int I) { while (!s.empty() && (s.begin()->first) < ...
11
CPP
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr int N = 2e5 + 5; int ans[N]; int degree[N]; int is_good[N]; vector<pair<int, int>> E[N]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; vector<pair<int, int>> e(m); for (int i = 0; i <...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, m, k, x[200009], y[200009]; set<int> alive; vector<int> kaaj; set<int> graph[200009]; int degree[200009], ans[200009]; void doit(int z) { if (alive.find(z) == alive.end()) return; alive.erase(z); if (graph[z].empty()) return; auto it = graph[z].begin(); whi...
11
CPP
#include <bits/stdc++.h> using namespace std; set<int> adj[200009]; set<int>::iterator it; int vis[200009]; pair<int, int> edg[200009]; vector<int> bad; int ses[200009]; int main() { int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= m; i++) { scanf("%d%d", &edg[i].first, &edg[i].second); adj[edg[i].fi...
11
CPP
#include <bits/stdc++.h> using namespace std; struct Edge { int x, y; } E[200010]; struct edge { int nxt, t, s; } e[200010 << 1]; int head[200010], edge_cnt; void add_edge(int x, int y, int z) { e[edge_cnt] = (edge){head[x], y, z}; head[x] = edge_cnt++; } bool ban[200010]; int Deg[200010], Q[200010], Ans[200010...
11
CPP
#include <bits/stdc++.h> using namespace std; int intcmp(const void *v1, const void *v2) { return *(int *)v1 - *(int *)v2; } int n, m, k; vector<pair<int, int>> v1v2index[200010]; int ea[200010], eb[200010]; int d[200010]; int curidx; bool deleted[200010]; int delcnt[200010]; int delnow; void dfs(int v) { if (deleted...
11
CPP
#include <bits/stdc++.h> const int N = 2e5 + 5; using namespace std; int n, m, k; int res[N]; int x[N], y[N]; int bac[N]; set<int> a[N]; set<pair<int, int> > S; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for (int i = 1; i <= m; i++) { cin >> x[i] >> y[i]; a...
11
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, m, k; cin >> n >> m >> k; vector<int> from(m), to(m); vector<vector<pair<int, int> > > adj(n); for (int i = (int)(0); i < (int)(m); ++i) { cin >> from[i] >> to[i]; from[i]--, to[i...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; set<int> S, G[N]; int A[N], B[N], C[N], n, m, k; void U(int u) { if (G[u].size() < k && S.erase(u)) for (auto v : G[u]) G[v].erase(u), U(v); } int main() { cin >> n >> m >> k; for (int i = 1; i <= m; ++i) { scanf("%d%d", A + i, B + i); ...
11
CPP
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 1; int n, m, k, ans; int du[MAX], X[MAX], Y[MAX], Ans[MAX]; vector<int> ve[MAX]; bool use[MAX]; void work(int x) { queue<int> qu; qu.push(x), use[x] = 1, --ans; while (!qu.empty()) { int tt = qu.front(); qu.pop(); for (int i = 0; i < ...
11
CPP
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long mod = 1000000007; const double e = 2.718281828459; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } long long gcd1(int a, int b) { if (!b) return a; return gcd(b, a % b); } long long pow_...
11
CPP
#include <bits/stdc++.h> using namespace std; int x[200010], y[200010]; set<int> s[200010]; queue<int> q, p; bool inq[200010]; bool w[200010]; int ans[200010]; int n, m, k, sum; void reset() { while (!q.empty()) q.pop(); while (!p.empty()) inq[p.front()] = false, p.pop(); } void BFS() { while (!q.empty()) { i...
11
CPP
#include <bits/stdc++.h> using namespace std; const long long linf = 1LL << 62; const int iinf = 1000000009; const double dinf = 1e17; const int Mod = 1e9 + 9; const int maxn = 1000005; set<pair<int, int> > s, sp; int n, m, k, u, v; int mp[maxn], rt; pair<int, int> sd[maxn], ds[maxn]; vector<int> vp[200005]; void up(in...
11
CPP
#include <bits/stdc++.h> using namespace std; const int OO = 0x3f3f3f3f; const double eps = (1e-10); stringstream out; int n, m, k, u, v, deg[200005]; bool isGood[200005]; vector<int> ans(200005); set<pair<int, int> > good; vector<pair<int, int> > edges(200005); vector<vector<pair<int, int> > > adj(200005); int main() ...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, m, cnt, k, tot, tp; int head[200005]; int sta[200005]; int dgr[200005]; int ans[200005]; bool usd[200005]; struct node { int fr; int to; int nxt; int mrk; } edge[400005]; void init() { cnt = 0; memset(head, -1, sizeof(head)); } void addedge(int f, int t) ...
11
CPP
#include <bits/stdc++.h> using namespace std; using lint = long long; const int INF = 0x3f3f3f3f; const double EPS = 1e-16; int N, M, K; int edges[200010][2], degree[200010]; set<int> graph[200010]; set<tuple<int, int>> nodes; int ans[200010]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout << setprec...
11
CPP
#include <bits/stdc++.h> using namespace std; template <class u> pair<u, u> ordered_pair(const u& a, const u& b) { return a < b ? make_pair(a, b) : make_pair(b, a); } int n, m, k; set<int> gr[201010]; vector<pair<int, int>> edge_list; set<pair<int, int>> removed_edges; struct cmp_deg { bool operator()(int u, int v)...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; unordered_set<int> e[N]; int n, m, k, ex[N], ey[N], i, ans, ot[N]; bool bb[N]; void del(int x) { bb[x] = 0; --ans; for (int y : e[x]) e[y].erase(x); for (int y : e[x]) if (bb[y] && e[y].size() < k) del(y); e[x].clear(); } int main() { ...
11
CPP
#include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(T x) { return x * x; } template <class T> inline T parse(const string &s) { T x; stringstream ss(s); ss >> x; return x; } const double EPS = 1e-12; const int INF = 1000 * 1000 * 1000; const long long LINF = INF * 1ll * INF; const do...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 200; int n, m, k, id[N], vis[N], ans[N]; vector<pair<int, int> > g[N]; struct node { int x, y; } e[N]; set<pair<int, int> > s; void change(int x) { if (vis[x]) return; auto it = s.lower_bound(make_pair(id[x], x)); pair<int, int> t = *it; s.eras...
11
CPP
#include <bits/stdc++.h> int n, m, k, ans; std::set<int> g[200005]; std::vector<std::pair<int, int> > qr; bool deleted[200005]; void check(int v) { if (deleted[v] || g[v].size() >= k) return; deleted[v] = true; ans--; for (auto &i : g[v]) g[i].erase(v); for (auto &i : g[v]) check(i); } int main() { std::ios...
11
CPP
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int N = 2e5 + 5; int n, m, k; vector<pair<int, int>> edge; set<int> adj[N]; bool gone[N]; vector<int> res; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for (int i = 1; i...
11
CPP
#include <bits/stdc++.h> using namespace std; long long binpow(long long a, long long n, long long mod) { long long ans = 1; while (n) { if (n & 1) ans = (ans * a) % mod; a = (a * a) % mod; n >>= 1; } return ans; } long long binpow(long long a, long long n) { long long ans = 1; while (n) { i...
11
CPP
#include <bits/stdc++.h> using namespace std; pair<int, int> edge[200000 + 324]; vector<int> adj[200000 + 324]; set<int> degree[200000 + 324]; set<int> friends; int ans[200000 + 324]; int k; void rem(int x) { set<int> elem_to_remove; for (auto bc : degree[x]) { elem_to_remove.insert(bc); degree[bc].erase(x)...
11
CPP
#include <bits/stdc++.h> using namespace std; const int maxN = 1e6 + 10; priority_queue<int> P; priority_queue<int, vector<int>, greater<int> > mP; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } int mod = 1000 * 1000 * 1000 + 7; long long ksm(int a, int b) { i...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, m, k; set<pair<int, int>> S; vector<int> A; vector<pair<int, int>> R; vector<vector<int>> G; set<pair<int, int>> B; int main() { cin >> n >> m >> k; R.assign(m, {0, 0}); A.assign(n, 0); G.assign(n, vector<int>(0, 0)); for (auto &i : R) { cin >> i.first ...
11
CPP
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n, m, k; cin >> n >> m >> k; vector<vector<int> > edges(m, vector<int>(2)); vector<vector<int> > graph(n + 1); vector<int> degrees(n + 1, 0); for (int i = 0; i < m; ++i) { scanf("%d %d", &edges[i][0], &edges[i][1]...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, m, k, x[200001], y[200001], ans[200001]; set<int> d[200001], s; queue<int> q; int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 1; i <= m; i++) scanf("%d%d", &x[i], &y[i]), d[x[i]].insert(y[i]), d[y[i]].insert(x[i]); for (int i = 1; i <= n; i++) if...
11
CPP
#include <bits/stdc++.h> using namespace std; void decreaseKey(set<pair<int, int> > &pairs, map<int, set<int> > &data, int decKey, int remVert) { pair<int, int> removePair; removePair.first = data[decKey].size(); removePair.second = decKey; pairs.erase(removePair); data[decKey].erase(remVert)...
11
CPP
#include <bits/stdc++.h> using namespace std; const int MAXN = 200100; int n, m, k; vector<pair<int, int> > veze; vector<pair<int, int> > graf[MAXN]; void load() { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < m; i++) { int a, b; scanf("%d%d", &a, &b); a--; b--; veze.push_back(pair<int, int>(...
11
CPP
#include <bits/stdc++.h> using namespace std; set<int> tt[200005]; set<int> ans; vector<pair<int, int>> ve; int n, m, k, x, y; int temp[200005]; void del(int x) { if (tt[x].size() < k && ans.find(x) != ans.end()) { ans.erase(x); for (auto i : tt[x]) { tt[i].erase(x); del(i); } } } int main()...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, m, k, x, y, deg[200010]; set<pair<int, int>> s; pair<int, int> p[200010]; vector<int> rez; set<int> v[200010]; map<bool, int> mp[200010]; void rem() { while (!s.empty() and s.begin()->first < k) { x = s.begin()->second; for (auto it : v[x]) { s.erase(...
11
CPP
#include <bits/stdc++.h> using namespace std; template <class X, class Y> void amax(X& x, const Y& y) { if (x < y) x = y; } template <class X, class Y> void amin(X& x, const Y& y) { if (x > y) x = y; } const int INF = 1e9 + 10; const long long INFL = (long long)1e18 + 10; const int MAX = 2e5 + 10; int n, m, k; int ...
11
CPP
#include <bits/stdc++.h> using namespace std; set<long long> V[400010]; long long n, m, k, D[400010], A[400010], B[400010], ans; signed main() { scanf("%lld%lld%lld", &n, &m, &k); ans = n; for (long long i = 1; i <= m; i++) { long long a, b; scanf("%lld%lld", &a, &b); A[i] = a; B[i] = b; D[a]+...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int ind[N], ans[N]; set<int> vec[N]; int U[N], V[N]; bool vis[N]; int n, m, K; int sum = 0; queue<int> q; void Top() { while (!q.empty()) { ++sum; int u = q.front(); q.pop(); ind[u] = 0; set<int>::iterator it; for (it = vec[...
11
CPP
#include <bits/stdc++.h> template <class C, class E> inline bool contains(const C& container, const E& element) { return container.find(element) != container.end(); } template <class T> inline void checkmin(T& a, T b) { if (b < a) a = b; } template <class T> inline void checkmax(T& a, T b) { if (b > a) a = b; } u...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int deg[N], del[N], u[N], v[N], aa[N], edg[N]; vector<pair<int, int> > adj[N]; int remove(queue<int> &q, int k) { int ans = 0; while (!q.empty()) { int x = q.front(); q.pop(); if (!del[x]) del[x] = 1, ans--; for (auto z : adj[x]) {...
11
CPP
#include <bits/stdc++.h> using namespace std; template <class T, class U> bool cmax(T& a, const U& b) { return a < b ? a = b, 1 : 0; } template <class T, class U> bool cmin(T& a, const U& b) { return b < a ? a = b, 1 : 0; } void _BG(const char* s) { cerr << s << endl; }; template <class T, class... TT> void _BG(con...
11
CPP
#include <bits/stdc++.h> using namespace std; const int maxN = 2e5 + 11; typedef int i_N[maxN]; int N, M, K; set<int> adj[maxN]; i_N deg, mark; int ans; pair<int, int> edge[maxN]; void dfs(int u) { if (mark[u]++) return; ans--; for (set<int>::iterator it = adj[u].begin(); it != adj[u].end(); it++) { int v = *...
11
CPP
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m, k; set<int> g[N]; pair<int, int> p[N]; set<pair<int, int>> st; bool inSet[N]; int ans[N], deg[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for (int i = 1; i <= m; i++) { int u, v; ...
11
CPP
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC optimize("-ffloat-store") using namespace std; const int MN = 200010; set<int> e[MN]; int from[MN], to[MN], deg[MN], vis[MN], res[MN]; int n, m, k, cnt; void deletev(int v) { ...
11
CPP
#include <bits/stdc++.h> using namespace std; int INF = (int)1e9; long long INFINF = (long long)1e18 + 10; const long double PI = 3.14159265358979323846; long long powermodm(long long x, long long n, long long mod) { long long result = 1; while (n > 0) { if (n % 2 == 1) result = (result * x) % mod; x = (x *...
11
CPP
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; int n; vector<set<int> > g(200000); vector<int> used(200000); int main() { int n, m, k; cin >> n >> m >> k; vector<int> x(m); vector<int> y(m); for (int i = 0; i < m; i++) { cin >> x[i] >> y[i]; x[i]--; y[i]--; g[x[i...
11
CPP
#include <bits/stdc++.h> inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') c = getchar(); while (c <= '9' && c >= '0') x = x * 10 + c - '0', c = getchar(); return x * f; } void print(int x) { if (x < 0) { putchar('-'); x = -x; } if (x >= 10) print(x / 10); pu...
11
CPP
#include <bits/stdc++.h> using namespace std; template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << " = " << h << endl; } template <class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) { while (*sdbg != ',') cerr << *sdbg++; cerr << " = " << h << ", "; _dbg(sdbg + 1, a...); } cons...
11
CPP
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005; int N, M, K; int A[MAXN]; int B[MAXN]; set<int> adj[MAXN]; int deg[MAXN]; set<pair<int, int> > st; bool inGraph[MAXN]; int ans[MAXN]; void update(int x) { if (!inGraph[x]) return; set<pair<int, int> >::iterator it = st.find(make_pair(deg[x], x))...
11
CPP
#include <bits/stdc++.h> using namespace std; using ll = long long; template <int n, class... T> typename enable_if<(n >= sizeof...(T))>::type _ot(ostream &, tuple<T...> const &) {} template <int n, class... T> typename enable_if<(n < sizeof...(T))>::type _ot(ostream &o...
11
CPP
#include <bits/stdc++.h> const int maxn = 2e5 + 3; int n, m, k, rest, eu[maxn], ev[maxn], ans[maxn]; std::set<int> G[maxn]; bool poped[maxn]; std::queue<int> q; void delEdge(int u, int v) { G[u].erase(v); G[v].erase(u); if (G[u].size() < k && !poped[u]) { poped[u] = true; --rest; q.push(u); } if (...
11
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, k, u; scanf("%d", &n); scanf("%d", &m); scanf("%d", &k); vector<pair<int, int> > adj[n + 5]; pair<int, int> edges[m + 5]; set<pair<int, int> > degree_set; set<pair<int, int> >::iterator it; bool isthere[n + 5]; int deg[n + 5]; ...
11
CPP
#include <bits/stdc++.h> using namespace std; struct P { int x, y, z; bool operator<(const P &a) const { return x < a.x; } }; vector<int> v[222228]; int a, c, i, b, n, m, k, d; int o[221111]; int l[221111]; int j[1111][9]; int e; int dx[10] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[10] = {1, 0, -1, 0, 1, -1, 1, -1}, dz...
11
CPP
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") using namespace std; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, m, k; cin >> n >> m >> k; vector<set<long long>> g(n + 1); vector<long long> deg(n + 1, 0); vector<pair<long long, long long>> v(m...
11
CPP
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long N = 3e5 + 10; long long x[N], y[N], deg[N]; vector<long long> vp[N]; long long removed[N]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, m, k; cin >> n >> m >> k; for (long long i = 1; i ...
11
CPP
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; set<pair<int, int> > sq; set<int> to[maxn]; int n, m, k; int a[maxn]; struct node { int l, r; } q[maxn]; void update() { while (sq.size() > 0 && (*(sq.begin())).first < k) { auto x = *(sq.begin()); sq.erase(sq.begin()); for (auto j...
11
CPP
#include <bits/stdc++.h> using namespace std; const int max6 = 1e6 + 6; const int oo = 2e9 + 9; const long long inf = 2e18 + 18; vector<pair<int, int> > g[max6]; pair<int, int> a[max6]; int q[max6]; int block[max6]; int deg[max6]; int del[max6]; int res[max6]; int n, m, need; int main() { cin >> n >> m >> need; for...
11
CPP
#include <bits/stdc++.h> using namespace std; int get() { char ch; while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-') ; if (ch == '-') { int s = 0; while (ch = getchar(), ch >= '0' && ch <= '9') s = s * 10 + ch - '0'; return -s; } int s = ch - '0'; while (ch = getchar(), ch >= '0' &...
11
CPP
#include <bits/stdc++.h> using namespace std; int n, m, k; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> k; vector<set<int>> g(n); vector<int> deg(n); set<pair<int, int>> cur; vector<pair<int, int>> edges; for (int i = 0; i < m; i++) { int a, b; cin >> a >...
11
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int k; cin >> k; vector<set<int>> g(n); vector<int> x(m), y(m); for (int i = 0; i < m; i++) { cin >> x[i] >> y[i], x[i]--, y[i]--; g[x[i]].emplace(y[i]); g[y[i]].emplace(x[i]); } int ans = n; queue<int> q...
11
CPP
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = double; using pll = pair<ll, ll>; using vll = vector<ll>; using vpll = vector<pll>; using vvll = vector<vll>; stack<ll> st; vector<ll> deg; vector<vector<ll>> g; vector<pair<ll, ll>> e; ll k; set<pair<ll, ll>> deleted; ll fixStuff() { ll d...
11
CPP
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9 + 7; int dir[8][2] = {-1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -1, 1, 1, -1, 1, 1}; template <typename S, typename T> ostream &operator<<(ostream &os, const pair<S, T> x) { os << "(" << x....
11
CPP
#include <bits/stdc++.h> using namespace std; const long long N = 201102; vector<long long> g[N]; set<pair<long long, long long> > s; long long n, m, k, v, u, d[N], a[N], b[N], ans[N]; pair<long long, long long> x; set<pair<long long, long long> >::iterator it; map<long long, bool> e[N]; int main() { scanf("%lld%lld%...
11
CPP