Source stringclasses 1
value | Date int64 2.01k 2.02k | Text stringlengths 22 783k | Token_count int64 20 394k |
|---|---|---|---|
Project_CodeNet | 2,017 | #include <cstdio>
#include <vector>
#include <cstring>
#include <cmath>
using namespace std;
#define iter(i, n) for (int i = 1; i <= n; ++i)
typedef pair<int, int> pii;
#define fi first
#define se second
const int inf = 1e9;
#define NR 101000
vector<int> e[NR];
pii f[NR];
int root, dep[NR], a[NR], n, K;
int abs(... | 548 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
int n, k, root = 0;
vector<vector<int>> g;
vector<int> res, l, r;
bool solve();
bool dfs(int now, int par, int dist);
int main() {
cin >> n;
g.resize(n);
l.assign(n, -3000000);
r.assign(n, 3000000);
res.resize(n, -1);
for (int i = 0; i < n - 1; ++i) {
int... | 523 |
Project_CodeNet | 2,016 | // Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
#ifdef LOCAL
#include "contest.h"
#else
#define dump(x)
#endif
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w;... | 794 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<int, pi> pii;
typedef set<int> si;
typedef vector<pi> vpi;
typedef double dl;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll MOD = 1e9+7;
#define lb lower_boun... | 761 |
Project_CodeNet | 2,020 | //=======================//
// coder: Andy - Tohrumi //
//=======================//
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), ... | 690 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
vvec<int> g(N);
... | 575 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,u,v,x,k;
int a[N];
bool vis[N];
int cnt,head[N];
struct edge{int next,to;}e[N<<1];
struct node
{
int id,v;
inline bool operator < (const node &x) const
{
return x.v<v;
}
};
inline void add(int u,int v)
{
cnt++;
e[cnt].next=head[u];
e[cnt... | 394 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
vector<int> adj[100010];
int arr[100010];
int meml[100010];
int memr[100010];
const int INF = 1000000;
bool f(int x, int p, int l, int r, int d)
{
if(arr[x] != -1)
{
if(arr[x] % 2 != d % 2 || arr[x] < l || arr[x] > r)
return 0;
l = r =... | 624 |
Project_CodeNet | 2,020 | /*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;... | 1,307 |
Project_CodeNet | 2,016 | #include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
using name... | 813 |
Project_CodeNet | 2,018 | //Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>
#include<memory.h>
#include<sstream>
#include<time.h>
#include <i... | 2,390 |
Project_CodeNet | 2,019 | #include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
int xx=0,ff=1;char ch=getchar();
while(ch... | 617 |
Project_CodeNet | 2,020 | ///////////////////////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
using namespace std;
///////////////////////////////////////////////////////////////////////////////
#define DEBUG 0
#define pb push_back
#define V ve... | 6,497 |
Project_CodeNet | 2,019 | #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lin... | 2,500 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
#define endl '\n'
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 ... | 770 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007
#define mx 10000... | 757 |
Project_CodeNet | 2,018 | #include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=1e5+5;
int n,k,tot,rt;
bool fake,bo[maxn];
int now[maxn],pre[maxn*2],son[maxn*2];
int l[maxn],r[maxn],odd[maxn],ans[maxn];
int read() {
int x=0,f=1;char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
for(;ch>='... | 563 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
#define rep(i,a,b) for(register int i=(a);i<(b);i++)
#define per(i,a,b) for(register int i=(b);i>=(a);i--)
#define For(i,a,b) for(register int i=(a);i<=(b);i++)
#define Forenska(it,c) for(register __typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define mp make_pair
#defi... | 705 |
Project_CodeNet | 2,016 | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <cassert>
typedef long... | 719 |
Project_CodeNet | 2,016 | /*
* AC 78 ms 14208 KB
*/
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define INF 1e9
int N, K;
vector<int> edge[100005]; // edge[i] connect from i to edge[i][j].
int v[100005]; // v[i] is written in vertex i
int par[100005]; // vertex i's parent is par[i]
int lb[100005], ub[1... | 768 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int BAD = -1e9;
int col[N];
bool have[N];
int par[N];
vector <int> good;
vector <int> g[N];
void dfs(int v, int pr) {
par[v] = pr;
have[v] = (col[v] != BAD);
for (auto to : g[v]) {
if (to != pr) {
... | 1,044 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r... | 773 |
Project_CodeNet | 2,016 | #include <climits>
#include <cstdio>
#include <vector>
using namespace std;
const int MAXN = 1E5 + 10;
int n;
int val[MAXN];
int dep[MAXN];
vector<int> E[MAXN];
int level;
int ansFlag = true;
int l[MAXN], r[MAXN];
int ans[MAXN];
void DFS1(int u, int pre){
if (val[u] >= 0){
ansFlag &= ((dep[u] ^ val[u]) & 1) == ... | 585 |
Project_CodeNet | 2,016 | #include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MAXN = 100100;
int A[MAXN], ... | 860 |
Project_CodeNet | 2,018 | #include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
const int SIZE=100005;
const int INF=100000005;
vector<int> mp[SIZE];
int id[SIZE],L[SIZE],R[SIZE];
bool ok=true;
void solve(int v,int p){
if(id[v]==-1){
L[v]=-INF;
R[v]=INF;
}
... | 515 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
int n,k;
int res[200005],vis[200005];
vector<int>e[200005],dis[200005];
void add(int f, int t) { e[f].push_back(t), e[t].push_back(f); }
bool check(int x, int y) { return x - y == 1 || y - x == 1; }
int main() {
scanf("%d",&n);
for(int i=1,u,v;i... | 381 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,... | 954 |
Project_CodeNet | 2,018 | #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
... | 753 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x... | 816 |
Project_CodeNet | 2,017 | #include <iostream>
#include <vector>
#include <list>
#include <queue>
int main() {
unsigned N;
std::cin >> N;
std::vector<std::vector<unsigned>> G(N);
std::vector<std::vector<unsigned>> G0(N);
for (unsigned i = 0; i < N - 1; ++i) {
unsigned x, y;
std::cin >> x >> y;
--x;
--y;
G0[x].push_... | 856 |
Project_CodeNet | 2,017 | #include <cstdio>
#include <iostream>
const int N = 1e5 + 5;
inline int Get() {
char ch;
while ((ch = getchar()) < '0' || ch > '9');
int Num = ch - '0';
while ((ch = getchar()) >= '0' && ch <= '9')
Num = (Num << 3) + (Num << 1) + ch - '0';
return Num;
}
const int inf = 1e9;
int n, m, que[N], qn, sgn[N], xl[N], x... | 868 |
Project_CodeNet | 2,018 | #include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 100000000
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
int n;
scanf("%d", &n);
vect... | 757 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
using namespace std;
#define N 100000 + 5
#define inf 123456789
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define Next(i, u) for(int i = h[u]; i; i = e[i].next)
struct edge{
int v, next;
}e[N << 1];
bool flag, book[N];
int n, m, u, v, tot, l[N], r[N], h[N], col[N], val[N];
int read(){... | 866 |
Project_CodeNet | 2,018 | //Zory-2018
//*******************头文件*******************
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int mymax(int x,int y) {return x>y?x:y;}
int mymin(int x,int y) {return x<y?x:y;}
//*******************全局常量*******************
const int MAXN=110000;
const int INF=0x3f3f3f... | 865 |
Project_CodeNet | 2,020 | // Copyright 2020 Nikita Golikov
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using ui64 = uint64_t;
#ifdef GOLIKOV
mt19937_64 rng(566);
#else
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
template <typename T>
T rnd_helper(T from, T to, true_type) {
return... | 1,479 |
Project_CodeNet | 2,020 | // ====================================
// author: M_sea
// website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;
int read() {
int X=0,w=1; char c=getchar... | 413 |
Project_CodeNet | 2,018 | #include<stdio.h>
#include<queue>
using namespace std;
const int inf=2147483647;
int abs(int x){return x>0?x:-x;}
int h[100010],nex[200010],to[200010],M;
void add(int a,int b){
M++;
to[M]=b;
nex[M]=h[a];
h[a]=M;
}
int v[100010];
struct cmp{
bool operator()(int x,int y){return v[x]<v[y];}
};
priority_queue<int,vect... | 332 |
Project_CodeNet | 2,017 | #include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int N, K, val[100000], mxs[100000], mns[100000];
vector<vector<int>> e;
void rec(int c, int p, int d, int &mx, int &mn, int &flag){
if(val[c] != -1){
if(flag == -1) flag = (va... | 581 |
Project_CodeNet | 2,020 | #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int lo[101010], hi[101010], val[101010];
int d[101010];
vector<int> g[101010];
const int INF = 1 << 30;
void dfs (int cur, int par, int depth) {
d[cur] = depth;
for (int child : g[cur]) if (child != par) dfs (child, cur, depth + 1);
}
void dfs2... | 643 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;
typedef long long ll; typedef long double db;
const int N = 5e5 + 5, M = 1e9 + 7;
vector<int> G[N];
int ans[N];
int main() {
int n;
cin >> n;
for (int i = 1; i < n; i++) {
int u, v;
cin >> u >> v;
... | 354 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
struct Edge {
Edge(int from_, int to_) : from(from_), to(to_) {}
int from;
int to;
};
struct Range {
Range() : lower(-(1<<27)), upper((1<<27)) {}
Range(int lower_, int upper_) : lower(lower_), upper(upper_) {}
int lower;
int upper;
};
Range nullWindow(-(1<<29), -(1<<29)-2);
bool... | 821 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second
#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define ... | 1,167 |
Project_CodeNet | 2,020 | #include <cstdio>
#include <cmath>
#include <vector>
#include <cassert>
#include <algorithm>
using i32 = int;
using i64 = long long;
constexpr i32 maxn = 100000;
inline i32 in() {
i32 n;
scanf("%d", &n);
return n;
}
std::vector<i32> to[maxn + 1];
inline void lnk(const i32 &u, const i32 &v) {
to[u].emplace_back(... | 675 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
cerr << fixed << setprec... | 888 |
Project_CodeNet | 2,017 | #include <iostream>
#include <vector>
using namespace std;
const int S = 100010;
const int INF = 1 << 30;
int N, K, L[S], R[S], P[S], ans[S];
bool valid;
vector<int> G[S];
void dfs(int p, int par=-1) {
for(auto to : G[p]) {
if(to == par) continue;
dfs(to, p);
L[p] = max(L[p], L[to] - 1);
... | 574 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
#define maxn 100005
#define pii pair<int,int>
#define endl '\n'
using namespace std;
vector<int> G[maxn];
bool vis[maxn];
int arr[maxn];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for(int i=1,u,v;i<n;i++) {
cin >> u >> v;
G[u].emplace_back(v);
G[v].emplace_back... | 334 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(... | 796 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
vector<vector<int> > G(101010);
int P[101010],L[101010],R[101010];
const int INF=1e7;
void bad(){
cout<<"No\n";
exit(0);
}
void dfs(int v,int p,int d){
if(P[v]!=INF){
if(P... | 518 |
Project_CodeNet | 2,020 | #include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end... | 948 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x) \
if (dbg) { \
cerr << #x << " = " << (x) << endl; \
}
#de... | 1,598 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i... | 1,024 |
Project_CodeNet | 2,016 | #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <list>
#include <stdio.h>
using namespace std;
#define REP(i,n) for(long long (i)=0;(i)<(long lon... | 917 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define ld long double
#define inf 1000000000
ll read(){
char ch=getchar(); ll x=0; int op=1;
for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
return x*op;
}
#... | 630 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000000;
typedef pair<int,int> P;
int v[100010],p[100010],lb[100010],ub[100010];
vector<int> G[100010];
bool f=false;
int n;
void dfs(int i,int... | 644 |
Project_CodeNet | 2,017 | #include<cstdio>
#include<vector>
#include<algorithm>
#define N 100002
using namespace std;
int s[N],cur[N],f[N],l[N],r[N],c[N];
vector<int>g[N];
int main(){
int n;scanf("%d",&n);
for(int i=1,u,v;i<n;i++){
scanf("%d%d",&u,&v);
g[u].push_back(v);
g[v].push_back(u);
}
for(int i=1;i<=n;i++)l[i]=-2e9,r[i]=2e9;
... | 487 |
Project_CodeNet | 2,016 | #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#inclu... | 738 |
Project_CodeNet | 2,018 | #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<bitset>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
namespace FastIO {
template<typename tp> inline vo... | 717 |
Project_CodeNet | 2,020 | # include <bits/stdc++.h>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define _USE_MATH_DEFINES_
#define ll lon... | 980 |
Project_CodeNet | 2,017 | #include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
int x;char c;
while((c=getchar())<'0'||c>'9');
for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
return x;
}
#define MN 100000
struct edge{int nx,t;}e[MN*2+5];
int h[MN+5],en,v[MN+5],l[MN+5],r[MN+5],o;
inline void ins(int x,int y)
{
... | 501 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).... | 965 |
Project_CodeNet | 2,019 | #include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/uno... | 1,444 |
Project_CodeNet | 2,018 | #include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAX_N = 100005, INF = 0x3f3f3f3f;
typedef pair<int, int> pii;
class Edge {
public:
int nxt, to;
} e[MAX_N << 1];
int head[MAX_N], cnt;
void addedge(int u, int v) {
e[++cnt] = (Edge){head[u], v}, head[u] = cnt;
e[++cnt] = (... | 723 |
Project_CodeNet | 2,019 | #include <queue>
#include <cstdio>
#include <cstring>
inline int Abs(const int x){return x>=0?x:-x;}
int n,k,c[100005];
int Head[100005],Next[200005],To[200005],En;
struct Rec
{
int x,v;
inline bool operator<(const Rec &o)const{return v>o.v;}
};
std::priority_queue<Rec> q;
inline void Add(const int x,const i... | 332 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
#define INF 1e9
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n; cin >> n;
vector<vector<int>> e(n);
for (int i = 0; i < n-1; i++) {
int a, b; cin >> a >> b; a--, b--;
e[a].emplace_back(b);
e[b].emplace_back(a);... | 634 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define N 100005
using namespace std;
typedef pair<int,int> Pair;
typedef long l... | 729 |
Project_CodeNet | 2,017 | #include <cstdio>
#include <algorithm>
int N, __K__, head[100001], next[199999], to[199999], E, q[100001], fa[100001];
int p[100001], w[100001], g[100001], L[100001], R[100001];
int main()
{
scanf("%d", &N);
for (int i = 1, u, v; i < N; i++)
{
scanf("%d%d", &u, &v);
next[++E] = head[u], to[E] = v, head[u] = E;
... | 937 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL... | 844 |
Project_CodeNet | 2,018 | #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int LEN = 1e5 + 5;
const int oo = 1e9;
int head[LEN];
struct edge {
int vet, next;
} E[LEN * 2];
int i, j, k, n, m, s, t, tot;
bool checkodd, checkval;
int L[LEN], R[LEN], isodd[LEN], ans[LEN];
void add(int u, i... | 781 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10,INF=1<<30;
struct edge{int nxt,to;}e[MAXN<<2];
int n,k,x,y,fst,head[MAXN],dep[MAXN],l[MAXN],r[MAXN],val[MAXN],tot=0;
void add(int from,int to)
{e[++tot].nxt=head[from];e[tot].to=to;head[from]=tot;}
void cal_dep(int x,int anc)
{
for(int i=head[x];i;... | 560 |
Project_CodeNet | 2,016 | #include <iostream>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
using P = pair<int, int>;
const int INF = (1 << 28);
const int MAX_N = 100010;
int lb[MAX_N], ub[MAX_N];
vector<int> graph[MAX_N];
int vid[MAX_N];
int main() {
int n, k;
cin >> n;
for (int i = 0; i < n - 1; ... | 738 |
Project_CodeNet | 2,019 | #include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <... | 1,328 |
Project_CodeNet | 2,018 | /*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
... | 3,127 |
Project_CodeNet | 2,020 | #ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typede... | 1,379 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
using namespace std;
#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp mak... | 898 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
using namespace std;
int n, m, a, b, arr[100001], cur = 1;
vector<int> adj[100001];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
vector<pair<int, int> > vec;
cin >> n;
fill(arr + 1, arr + n + 1, -1);
for(int i=1; i<n; i++){
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a... | 404 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
int n;
cin >> n;
vector<vector<int>> v(n);
for(int i = 0; i < n-1; i++)
{
int a, b;
cin >> a >> b;
a--;b--;
v[a].push_back(b);
v[b].push_back(a);
}
vector<ll> ans(n);
... | 418 |
Project_CodeNet | 2,020 | #include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl... | 985 |
Project_CodeNet | 2,018 |
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X... | 971 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...)
#endif
void solve(){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
int N; std::cin >> N;
std::vector<std::vector<int>> adjacent(N);
for(int i = 0; i < N-1; ++i){
int a, b; std::cin >> a >> b;
--a,... | 399 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;
#... | 735 |
Project_CodeNet | 2,019 | //todo 文字数を少なくする
//mintより高速に計算したい時用に modmul() modadd (正の値限定) を作る
//#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
using namespace std;
//@起動時
struct initon {
initon() {
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(16);
srand((unsigned)... | 31,771 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
for(;b;b >>= 1,a = a * a % mod) if(b & 1)
ans = ans * a % mod;
return ans;
}
... | 819 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
const int N = 100005, inf = 0x3f3f3f3f;
int n, head[N], tot;
struct edge { int to, nxt; } e[N << 1];
void link(int x, int y) {
e[++tot] = (edge) { y, head[x] }, head[x] = tot;
e[++tot] = (edge) { x, head[y] }, head[y] = tot;
}
int p[N], rec, l[N], r[N];
void dfs0(int x, int f = 0, bool dep... | 604 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1e9
#define Inf 1000000000000000000LL
using namespace std;
typedef pair<int,int>pii;
int n,m;
vector<int>G[100010],ord;
int par[100010],val[100010];
int ll[100010],rr[100010];
bool known[100010],vis[100010];
bool pr[1000... | 543 |
Project_CodeNet | 2,020 | // ZapZu's code hohoho
// #pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vecto... | 915 |
Project_CodeNet | 2,019 | #include<bits/stdc++.h>
#define fr(i,n) for(int i=0;i<(n);++i)
#define foor(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,n) for(int i=(n);i--;)
#define roof(i,b,a) for(int i=(b);i>=(a);--i)
#define elsif else if
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x))
#define Reverse(x) reverse(all(x))
#define PQ... | 3,924 |
Project_CodeNet | 2,018 | #include<bits/stdc++.h>
const int N = 1e5 + 5;
const int inf = 1e9 + 7;
using namespace std;
vector <int> adj[N];
int n, k, l[N], r[N], ans[N];
void Merge(int& l, int& r, int L, int R){
if (l == -inf) l = L, r = R;
else{
if ((l + L) % 2 != 0) {cout << "No"; exit(0);}
l = max(l, L);
r =... | 521 |
Project_CodeNet | 2,019 | #include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adjlist[100005];
int p[100005];
int d[100005];
int l[100005], r[100005];
int ans[100005];
int root;
bool valid =true;
void dfs(int u){
for (auto v : adjlist[u]){
if (v == p[u]) continue;
d[v] = d[u]+1;
p[v] = u;
dfs(v);... | 628 |
Project_CodeNet | 2,018 | #include <bits/stdc++.h>
using pii = std::pair<int, int>;
struct Node {
int min{-10000000}, max{10000000};
std::list<int> edges;
bool visited{};
};
std::vector<Node> tree;
pii construct(int, int, int, int);
int main()
{
int n;
scanf("%d", &n);
tree.resize(n);
for (int i = 0; i < n - 1; i++)
{
int a, b;
... | 571 |
Project_CodeNet | 2,018 | #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define int long long
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/
int N, K;
int A[110000],... | 860 |
Project_CodeNet | 2,020 | #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define in insert
#define REP(i,n) for (int i = 1; i <= n; i++)
#define ... | 531 |
Project_CodeNet | 2,017 | #include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long LL;
typedef double db;
int get(){
char ch;
while(ch=getchar(... | 896 |
Project_CodeNet | 2,016 | #include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
typedef double db;
const ll INF = 0xffffffffff;
p cap[100000];
ll N,A[100000]... | 751 |
Project_CodeNet | 2,016 | #include <bits/stdc++.h>
#define MAXN (100010)
int n, k;
int l[MAXN], r[MAXN];
bool has[MAXN];
std::vector<int> mat[MAXN];
bool union_seg(int &lu, int &ru, int lv, int rv, int odd, bool &mark){
if(!mark){
lu = lv;
ru = rv;
mark = true;
}
else{
lu = std::max(lu, lv);
ru = std::min(ru, rv);
}
if(lu > ru... | 613 |
Project_CodeNet | 2,016 | #include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR... | 1,433 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin(... | 623 |
Project_CodeNet | 2,016 | #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> void setmax(T &... | 620 |
Project_CodeNet | 2,017 | #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int MX=100011;
struct Edge{int t,nxt;}e[MX<<1];
int ec,hed[MX];
int n,k;
int v[MX],L[MX],R[MX],typ[MX];
int ans[MX];
inline void ade(int f,int t){++ec;e[ec].nxt=hed[f];hed[f]=ec;e[ec].t=t;}
#define FE(i) for(int (i)=... | 582 |
Project_CodeNet | 2,020 | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int oo = 1e18 + 7;
int n, k, ans[100005], d[100005];
ii range[100005];
vector<int> Adjlist[100005];
... | 698 |
Project_CodeNet | 2,018 | //#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include... | 1,752 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.