Source stringclasses 1
value | Date int64 2.01k 2.02k | Text stringlengths 22 783k | Token_count int64 20 394k |
|---|---|---|---|
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
using namespace std;
#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(... | 775 |
Project_CodeNet | 2,016 | /* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n)... | 1,319 |
Project_CodeNet | 2,019 | #include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
int n; cin >> n;
vector<vector<int>>graph(n);
for (int i = 0, a, b; i < n - 1; i++) {
cin >> a >> b; a--; b--;
graph[a].push_back(b); graph[b].push_back(a);
}
int k; cin >> k;
... | 385 |
Project_CodeNet | 2,018 | #include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;... | 632 |
Project_CodeNet | 2,017 | #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)... | 863 |
Project_CodeNet | 2,017 | #include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.... | 1,083 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std ;
#define N 100010
#define inf 0x3f3f3f3f
int n , K , d[ N ] ;
int head[ N << 1 ] , cnt , vis[ N ] ;
struct edge {
int to , nxt ;
}e[ N << 1 ] ;
priority_queue< pair<int,int> , vector< pair<int,int> > , greater< pair<int,int> > > q ;
void ins( int u , int v ) {
e[ ++... | 485 |
Project_CodeNet | 2,019 | #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
ll n,k;
ll p[N];
vector<ll> g[N];
ll l... | 583 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int seen[maxn], unk[maxn], par[maxn], l[maxn], r[maxn];
vector<int> e[maxn], ord;
void dfs(int u, int v){
ord.push_back(u);
for(int to : e[u]) if(to != v) dfs(to, u);
}
int main(){
int n; cin >> n;
for(int i = 0; i < n - 1; i++){
int x, y; cin... | 714 |
Project_CodeNet | 2,017 | #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define debug(x) cout << #x << " => " << x << endl
const int MAX_N = 7 + 100000;
vector<int... | 511 |
Project_CodeNet | 2,018 | #include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;
//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i... | 1,043 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
boo... | 624 |
Project_CodeNet | 2,016 | #include <cstdio>
#include <cstring>
#include <vector>
const int N = 100000 + 10, INF = 0x3f3f3f3f;
int n, m;
std::vector<int> adj[N];
int fa[N], dep[N];
int v[N], p[N];
int l[N], r[N];
void dfs(int a) {
for (int i = 0; i < adj[a].size(); ++i) {
int b = adj[a][i];
if (b != fa[a]) {
fa[b] = a;
... | 696 |
Project_CodeNet | 2,019 | #include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#in... | 783 |
Project_CodeNet | 2,019 | #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#inc... | 828 |
Project_CodeNet | 2,018 | #include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
#define RG register
using namespace std;
const int N=1e5+10;
struct dabt{ int next,to; }e[N<<1];
struct node{
int id,num;
bool operator <(const node&x)const{return x.num<num;}
};
int head[N],k,n,m,num[N];
bool vis[N],fx[N];
templat... | 486 |
Project_CodeNet | 2,018 | /*
cat <<EOF >mistaken-paste
*/
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define BIG 2000000007
#define VERYBIG 200000000000007LL
#define MOD 1000000007
typedef uint64_t ull;
ty... | 5,339 |
Project_CodeNet | 2,017 | #include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <utility>
typedef long long ll;
typedef std::pair<int, int> pii;
#define mp std::make_pair
int n, k, ans[100005];
bool vis[100005];
int head[100005], next[100005 << 1], to[100005 << 1], ed = 0;
int deg[100005];
void AddEdge(int u, int v) {
next[++e... | 608 |
Project_CodeNet | 2,020 | #include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_se... | 1,200 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, ll> P;
const ll INF = 10e17;
#define cmi... | 600 |
Project_CodeNet | 2,018 | #include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#define pii pair<int,int>
#define maxn 100005
using namespace std;
priority_queue<pii> q;
vector<int> v[maxn];
int n,k,A,B,a[maxn];
bool used[maxn],has[maxn];
int main()
{
scanf("%d",&n);
for(int i=0;i<n-1;i++)
{
scanf("%d%d",&... | 382 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<... | 675 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
using namespace std;
int main(){
size_t N;
cin >> N;
vector<vector<size_t>> edge(N);
for(size_t i = 1, a, b; i < N; ++i){
cin >> a >> b;
edge[--a].push_back(--b);
edge[b].push_back(a);
}
size_t K;
cin >> K;
vector<unsigned long> ans(N, ~0U... | 294 |
Project_CodeNet | 2,016 | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
const int INF = 1e9;
vector<int> G[100010];
pair<int, int> mem[100010];
void dfs(int v, int p){
int l, r;
tie... | 566 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
using namespace std;
#define __unique(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));
#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define FOR(i, a, b) for(int i = a, _b = (b) ; i <= _b ; i++)
#define FORD(i... | 1,190 |
Project_CodeNet | 2,018 | #include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
int n,k,d[100005];
vector <int> g[100005];
int main()
{
memset(d,0x3f3f3f3f,sizeof(d));
cin>>n;
for (int i=0;i<n-1;++i)
{
int x,y;
cin>>x>>y;
g[x].push_back(y);
g[y].push_back(x);
}
priority... | 352 |
Project_CodeNet | 2,016 | #define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.... | 957 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a -... | 594 |
Project_CodeNet | 2,018 | #include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i... | 589 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP... | 1,065 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1<<30;
struct Hoge {
int a, b;
};
int N, K;
vector<vector<int>> G;
vector<int> P;
vector<Hoge> hoge;
void f(int p, int q) {
if (P[p] != INF) {
hoge[p].a = hoge[p].b = P[p];
} else {
hoge[p].a = hoge[q].a - 1;
hoge[p].b = hoge[q].b + 1;
}
for (int... | 597 |
Project_CodeNet | 2,017 | #include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << ": " << (x) << endl
typedef vector<pair<int, vector<int> > > Graph;
const int INF = INT_MAX;
bool dfs(Graph &G, int par, int v, int upper, int lower,
pair<int, int> range[]) {
int P = G[v].first;
if (P != INF) {
if (((upp... | 706 |
Project_CodeNet | 2,016 | #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include ... | 1,013 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
void NO() {
cout << "No" << endl;
exit(0);
}
class Tree {
public:
Tree(const auto& G, const auto& W) : child(G.size()), interval(G.size(), {-INF, INF}) {build(G, W);}
void solve() {
function<void(int)>... | 695 |
Project_CodeNet | 2,018 | #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (100010)
int n, m;
vector<int>e[N];
int l[N];
int ... | 721 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
const int N = 123456;
const int INF = 1e9;
int n;
vector<pair<int, int>> g[N];
int dist[N];
int m;
int d[N];
void gg() {
puts("No");
exit(0);
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n - 1; i++) {
int a, b;
scanf("%d %d", &a, ... | 485 |
Project_CodeNet | 2,017 | /*
_____________ ______________ __
/ _________ /\ /_____ _____/\ / /\
/ /\ / / \\ / /\ \ \ / / \
/ / \_____/ / / \__/ / \____\/ / / /
/ / / / / / / / / / / /
/ / / / / / ... | 1,203 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
using namespace std;
struct range {
int type, left, right;
range() {}
range(int _type, int _left, int _right): type(_type), left(_left), right(_right) {}
};
range intersec(range x, range y) {
if (x.type == 0 || y.type == 0) {
return range(0, -1, -1);
}
if (x.... | 729 |
Project_CodeNet | 2,017 | #include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
int h[maxn],go[maxn*2],nxt[maxn*2],L[maxn],R[maxn],v[maxn];
bool bz[maxn];
int i,j,k,l,t,n,m,tot;
bool czy;
void add(int x,int y){
go[++tot]=y;
nxt[tot]=h[x];
h[x]=tot;
}
void dfs(int x,int y){
in... | 620 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int inf = 1e6;
inline int read()
{
int p=0; int f=1; char ch=getchar();
while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
return p*f;
}
struct node{int x,y,next;}edge[N]; in... | 754 |
Project_CodeNet | 2,020 | /* author: Kite_kuma
created: 2020.09.24 11:52:59 */
// #ifdef LOCAL
// #define _GLIBCXX_DEBUG
// #endif
#include <bits/stdc++.h>
using namespace std;
#pragma region aliases
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define rrep(i, n) for(long long i = (n)-1; i > -1; i--)
#define Rep(i, m, n) for(long l... | 7,629 |
Project_CodeNet | 2,017 | #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int n,k;
vector<int> G[100005];
int val[100005];
bool vis[100005];
pair<int,int> dp[100005];
void check(int x,int flag){
vis[x]=true;
if (val[x]!=-1){
if (flag==-1){
flag=1-(val[x]%2);
}
else ... | 741 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define maxn 100005
inline ll read()
{
ll x=0,w=0;char ch=getchar();
while(!isdigit(ch))w|=ch=='-',ch=getchar();
while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return w?-x:x;
}
vector<int>G[maxn];
int n,k;
int L[maxn],R[... | 599 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 100000000
vector<int> P;
bool f = true;
vector<pair<int,int>> range;
void dfs(int now,int parent,auto &E){
int l=-Inf,r=Inf;
if(P[now]!=-1){
l = P[now];
r = l;
}
for(in... | 594 |
Project_CodeNet | 2,017 | #include <cstdio>
#include <cstring>
#include <algorithm>
#define MAXN 100010
using namespace std;
struct edge{
int to,next;
edge(int _to=0,int _next=0):to(_to),next(_next){}
}e[MAXN<<1];
int n;
int g[MAXN],nume;
int dep[MAXN],pre[MAXN];
int vs[MAXN][2];
int w[MAXN],numw,pt[MAXN];
int b[MAXN],ans[MAXN];
void addEd... | 715 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
typedef std::pair <int, int> pr;
const int N = 100054, M = N * 2, INF = 0x3f3f3f3f;
int n, E = 0;
int to[M], first[N], next[M];
int d[N];
std::priority_queue <pr, std::vector <pr>, std::greater <pr> > pq;
inline void addedge(int u, int v) {
to[++E] = v, next[E] = first[u], first[u] = E;
to... | 439 |
Project_CodeNet | 2,017 | #include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define ran 111111
#define lim 11111111
int n, m;
vector<int> e[ran];
pair<int, int> v[ran];
bool flag;
bool merge(pair<int, int> &a, pair<int, int> b) {
if (b.first <= -lim) return true;
b.first--; b.second++;
if (a.first <= -lim) {
a=b... | 522 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int,int> p;
int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};
#de... | 921 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begi... | 1,006 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using P = pair<int, int>;
const int MX = 100005;
const int INF = 1e9;
int n, k, a, b, v, p;
vector<int> G[MX];
P ran[MX];
P dfs(int p, int t){
int l,r, nl, nr;
tie(nl, nr) = ran[t];
bool out = false;
for(int nx: G[t]) if(nx != p)... | 411 |
Project_CodeNet | 2,020 | #include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <array>
#inc... | 1,907 |
Project_CodeNet | 2,019 | #include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctyp... | 5,291 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) f... | 822 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
// template {{{
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
... | 2,634 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
scanf("%d",&n);
vector<vector<int>>g(n);
for(int i=0;i<n-1;i++)
{
int a,b;
scanf("%d%d",&a,&b);
a--;
b--;
g[a].push_back(b);
g[b].push_back(a);
}
vector<int>d(n,-1);
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int... | 323 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
const int MAX_N = 1e5 + 10;
int N, Fix[MAX_N], Ans[MAX... | 810 |
Project_CodeNet | 2,018 | #include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
static const int INF = 0x3f3f3f3f;
void ex() {
puts("No");
exit(0);
}
int main() {
int n;
scanf("%d", &n);
vector<vector<int>> g(n);
for (int i = 0; i < n - 1; i ++) {... | 967 |
Project_CodeNet | 2,018 | #include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#define ll long long
#define inf 1e9
#define eps 1e-10
#define mod 9901
#define mkp make_pair
using namespace std;
int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1... | 886 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int N = 1e5+6, inf = -1e9-7;
int n, w[N];
vector <int> adj[N];
signed main(){
cin >> n;
for (int ... | 390 |
Project_CodeNet | 2,019 | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#includ... | 811 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
const int N_ = int(1.1e5);
int N;
vector<int> gph[N_];
int low[N_], high[N_];
void dfs (int u, int p = -1) {
for(int v : gph[u]) if(v != p) {
low[v] = max(low[v], low[u] - 1);
high[v] = min(high[v], high[u] + 1);
dfs(v, u);
low[u] = max(low[u], low[v... | 697 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int int64_t
#define ii pair<int,int>
#define dd pair<double,double>
#define vi vector<int>
#define pb pu... | 600 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
// clang-format off
#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl
#define rep(i, n) for (i... | 1,134 |
Project_CodeNet | 2,016 | #include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef... | 815 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5;
vector<int> g[N];
vector<int> v(N, -1);
int ml[N], mr[N];
int imp = 0;
pair<int, int> dfs(int i, int p, int l, int r) {
if(v[i] != -1) {
if((l % 2 + 2) % 2 != v[i] % 2 || (v[i] < l || v[i] > r)) {
imp = 1;
cerr << ... | 577 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
ve... | 628 |
Project_CodeNet | 2,019 | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> Range;
typedef pair<Range, int> Info;
Info info[100000];
vector<int> G[100000];
int P[100000];
bool dfs(int v, in... | 833 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;
bool dfs1(int v,int parent,int parity,const vector<vector<int>> &g,const vector<int> &num){
if(num[v]!=-inf&&num[v... | 608 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair... | 735 |
Project_CodeNet | 2,016 | #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <limits>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(... | 878 |
Project_CodeNet | 2,020 | #pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#incl... | 6,396 |
Project_CodeNet | 2,016 | #include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long LL;
typedef pair<int,in... | 1,025 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
// getchar
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *... | 1,065 |
Project_CodeNet | 2,018 | #include <set>
#include <map>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm... | 824 |
Project_CodeNet | 2,020 | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long llo;
#define a first
#define b second
#define endl "\n"
vector<llo> adj[100001];
llo col[100001];
llo inf;
llo par[1000000];
pair<llo,llo> ran[100001];
void dfs(llo no,llo parr=-1,llo l=-1,llo ... | 931 |
Project_CodeNet | 2,017 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pa... | 781 |
Project_CodeNet | 2,017 | #include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef long doubl... | 595 |
Project_CodeNet | 2,018 | #include <cstdio>
#include <cstring>
using namespace std;
const int N=100005;
const int INF=1e9;
int n,m;
int a[N];
int h[N],tot,dep[N];
struct Edge{
int v,next;
}e[N*2];
int f[N],g[N],ans[N];
inline int max(int x,int y){
return x>y?x:y;
}
inline int abs(int x){
return x>=0?x:-x;
}
void addEdge(int u,int v)... | 832 |
Project_CodeNet | 2,016 | #include<bits/stdc++.h>
using namespace std;
#define pb push_back
int N,K;
vector<int>G[111111];
vector<int>P[1111111];
int ans[111111];
bool F[111111];
int main()
{
scanf("%d",&N);
for(int i=0;i<N;i++){
ans[i]=-1;F[i]=false;
}
for(int i=0;i<N-1;i++){
int A,B;
scanf("%d%d",&A,&B);A--;B--;
G[A].pb(B);
G[B]... | 370 |
Project_CodeNet | 2,017 | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
T i=0;char c;
while(!isdigit(c=getchar())&&c!='-');
bool flag=c=='-';
flag?c=getchar():0;
w... | 703 |
Project_CodeNet | 2,020 | #include <iostream>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <utility>
#include <vector>
std::vector<std::vector<int>> edge;
std::vector<std::pair<int, int>> range;
std::vector<int> res;
constexpr int inf = std::numeric_limits<int>::max();
constexpr std::pair<int, int> all_ok(-1, -1);
const... | 660 |
Project_CodeNet | 2,020 | #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterat... | 867 |
Project_CodeNet | 2,017 | #include<bits/stdc++.h>
const int N=1e5+77,inf=0x3f3f3f3f;
int n,k;
struct edge{
int to,nx;
}e[N*2];
int e0[N],ep=2,L[N],R[N],tp[N],zv=-1;
bool ed[N];
void maxs(int&a,int b){if(a<b)a=b;}
void mins(int&a,int b){if(a>b)a=b;}
void upd(int a,int b){
maxs(L[a],L[b]-1);
mins(R[a],R[b]+1);
}
void f1(int w,int pa){
tp[w]=t... | 536 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define long ll
int main(void) {
cin.tie(0); ios::sync_with_stdio(false);
ll n;
cin >> n;
vector<vector<ll>> G(n);
for(ll i=0; i<n-1; i++) {
ll x, y;
cin >> x >> y;
x--, y--;
G[x].push_back(y);
... | 554 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n; cin >> n;
vector<vector<int>> g(n);
for (int _ = 1; _ < n; _++) {
int x,y;
cin >> x >> y;
x--;y--;
g[x].emplace_back(y);
g[y].emplace_back(x);
}
vector<int> a(n);
vector<bool> trk(n);
... | 327 |
Project_CodeNet | 2,020 | #pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define int long long
#define ll long long
//#define int unsigned long long
#define pb push_back
//#define double long double
using namespace std;
using namespace __gnu_pbds;
typedef tree<... | 818 |
Project_CodeNet | 2,020 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#includ... | 893 |
Project_CodeNet | 2,017 | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x... | 520 |
Project_CodeNet | 2,018 | #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 100010
int n,k,p[N],a[N],b[N];
vector<int> v[N];
int D(int x,int y){
int r=x%y;
if(r<0)return r+y;
return r;
}
v... | 561 |
Project_CodeNet | 2,020 | #define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _ov... | 1,249 |
Project_CodeNet | 2,020 |
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin... | 399 |
Project_CodeNet | 2,016 | #include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int Nmax = 1e5;
int N,K,A[Nmax],B[Nmax],V[Nmax],P[Nmax];
vector<int> graph[Nmax];
long upper[Nmax], lower[Nmax], depth[Nmax];
int dfs(int node, int par){
depth[node] = par >= 0 ? depth[par]+1 : 0;
for(int i=0; i<graph[... | 621 |
Project_CodeNet | 2,019 | #include <vector>
#include <iostream>
using namespace std;
int LB[100100], UB[100100], INF = 1<<30;
vector<int> adj[100100];
bool check(int v, int p, int r) {
if (LB[v] == UB[v] && (LB[v] - r) % 2 != 0) return false;
for (int u : adj[v]) if (u != p && !check(u, v, 1-r)) return false;
return true;
}
bool d... | 481 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int inf = 1e9;
vector<int> lf, rg;
vector<char> any;
int n;
vector<vector<int> > g;
vector<int> val... | 923 |
Project_CodeNet | 2,016 | #include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>... | 1,408 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#def... | 1,278 |
Project_CodeNet | 2,016 | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <li... | 801 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
class segtree {
struct node {
long long v ; // default value for the leafs
long long lazy = 0; // no lazy value
void apply(int l, int r, long long x) {
v -= x;
// set v to the new value of range [l , r] when updated wit... | 1,277 |
Project_CodeNet | 2,019 | #include <cstdio>
#include <algorithm>
using namespace std;
#define N 100010
#define inf 0x3f3f3f3f
int n,K,num,tot,cnt,a[N],b[N],vis[N],d[N],h[N],low[N],up[N];
struct node{int to,next;}mp[N<<1];
inline bool cmp(int x,int y){return d[x]<d[y];}
inline void ins(int x,int y){
mp[++num].to=y;mp[num].next=h[x];h[x]=num;
... | 569 |
Project_CodeNet | 2,018 | #include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<math.h>
#include<stdlib.h>
using namespace std;
typedef pair<int, int>pii;
vector<int>pat[202020];
int ans[202020];
bool flag[202020];
void no()
{
printf("No\n");
exit(0);
}
int main()
{
int num;
scanf("%d", &num);
for (int i = 0; i < ... | 433 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.