text stringlengths 10 22.5k | status stringclasses 2
values | name stringlengths 9 26 |
|---|---|---|
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2e5 + 5, M = 4e7;
constexpr int INF = 0x3f3f3f3f;
int n, m, tot = 1, lnk[N], cur[N], ter[M], nxt[M], cap[M], cost[M], dis[N], ret;
bool vis[N];
int cnt = 2;
void add(int u, int v, int w, int c) {
ter[++tot] = v, nxt[tot] = lnk[u], lnk[u] = tot, cap[t... | passed | 10_std.cpp |
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main (){
ios_base::sync_with_stdio(0), cin.tie(0);
int t;
string s;
cin >> t;
while (t--){
cin >> s;
int n = s.size(), c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < n; i++){
if (s[i] == '0')
c1 -= (i & 1 ? 1 : -1);
else if... | passed | 48_std.cpp |
#include<bits/stdc++.h>
constexpr int maxn = 5e5 + 10;
int n, m;
std::vector<int> to[maxn], son[maxn], par[maxn];
int vis[maxn], dfn[maxn], rdfn[maxn], dn;
int dep[maxn], fa[maxn][20];
int len;
inline void dfs1(int u) {
dfn[u] = ++dn, vis[u] = 1;
dep[u] = dep[fa[u][0]] + 1;
for (int i = 1; i < 20; i++) {
... | passed | 70_std.cpp |
#include<bits/stdc++.h>
// #include<bits/stdc--.h>
using i64 = long long;
#define all(x) std::begin(x), std::end(x)
void solve() {
int n;
std::cin >> n;
if (n == 1) {
std::cout << ".\n";
return;
} else if (n == 2) {
std::cout <<
R"( .
. .
)";
return;
} else if (n ==... | passed | 73_std.cpp |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MAXV = 200005;
struct Seg {
int l, r;
long long y;
bool enter;
Seg... | passed | 94_std.cpp |
#include <bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int,int>;
#define F first
#define S second
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using ll = long long;
typedef vector<int> vi;
#define pb push_back
#define vt ve... | passed | 95_std.cpp |
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<vector>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int word;
typedef unsigned short hword;
typedef unsigned char byte;
struct game{
char s[9];
inline game(){}
inline game(const game &g)=default;
inlin... | passed | 50_std.cpp |
#include <bits/stdc++.h>
using namespace std;
string cut(string n) {
for (int i = 0; i < n.size(); i++)
{
if (n[i] >= 'A' && n[i] <= 'Z') return n.substr(i);
}
return "";
}
int main() {
int N;
scanf("%i", &N);
string n;
getline(cin, n);
vector<pair<string, string>> names;... | passed | 57_std.cpp |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef __int128 i128;
const int maxn = 1e5 + 5;
struct point3
{
int x, y, z;
}q[maxn];
struct point
{
ll x, y;
bool op;
bool operator == (const point &b)const { return x == b.x && y == b.y && op == b.op; }
... | passed | 78_std.cpp |
#include <cstdio>
using i32 = int;
constexpr i32 N = 5000;
i32 n, a[N + 1], b[N + 1], c[N + 1];
bool f[N + 1];
signed main() noexcept {
i32 Test;
for (scanf("%d", &Test); Test; --Test)
[]() {
scanf("%d", &n);
for (i32 i = 1; i <= n; ++i) scanf("%d", &a[i]);
for (i32 i = 1; i <= n; ++i) f[i] = false;
f[0... | passed | 27_std.cpp |
#include<bits/stdc++.h>
#ifdef LOCAL
#define debug(...) printf(__VA_ARGS__)
#define edebug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#define edebug(...)
#endif
#define int ll
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define nrep(i, x, y) for(int i = x; i >= y; --i)
#define ll long long
#define ... | passed | 75_std.cpp |
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve () {
int n, a, b;
cin >> n >> a >> b;
vector dp (n + 1, vector <int> (n + 1));
dp[0][0] = 1;
vector <set <int>> st (n + 1);
st[0].insert (0);
auto check = [&] (int x, int y) {
if (x > n || y > n) {
... | passed | 110_std.cpp |
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#incl... | passed | 47_std.cpp |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
mt19937_64 rng(time(0));
ll get(ll l, ll r) {
return uniform_int_distribution<ll>(l, r)(rng);
}
constexpr db eps = 1e-9;
void solve() {
int d, w;
cin >> d >> w;
vector<string> roll(d);
set<string> ws;
int S ... | passed | 118_std.cpp |
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int INF = 0x3f3f3f3f;
const i64 mod = 1e9 + 7;
const int N = 200005;
i64 n;
void solve() {
i64 l, r;
cin >> l >> r;
if(2*l > r) {
if((r-l)%2) {
cout << "Bob\n";
}
else {
cout << "Alice... | passed | 68_std.cpp |
#include <bits/stdc++.h>
#define int long long
#define INF 0x3f3f3f3f
#define llINF 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(), x.end()
#define alll(x, t) x.begin() + t, x.end()
#define rall(x) x.rbegin(), x.rend()
#define ull unsigned long long
#define PII pair<int, int>
#define fi first
#define se second
#define pb ... | passed | 82_std.cpp |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int maxn = 1e6 + 100;
const int lg = 31;
const int mod = 1e9 + 7;
const int inf = 3e8 + 100;
const ll INF = 1e18;
#define rep(i, a, b) for(in... | passed | 32_std.cpp |
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
const ll inf=4e18;
int n,k,c[N],to[N],nc[N],num[N],nv[N],p[21][N],fa[N],ansc[N];
ll ansv[N];
vector<int>son[N];
int prt[N],up[N],dep[N],up1[N];
int gf(int x){if(x==prt[x])return x;return prt[x]=gf(prt[x]);}
void merge(int x,int y){x=g... | passed | 29_std.cpp |
#include <bits/stdc++.h>
#define ll long long
#define poly vector<int>
using namespace std;
const int N = 1e6 + 10, P = 998244353;
inline int ksm(int a, int b, int mod)
{
int z = 1;
while (b)
{
if (b & 1)
z = 1ll * z * a % mod;
a = 1ll * a * a % mod;
b >>= 1;
}
re... | passed | 71_std.cpp |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, n) for (int i = 0; i < (n); i += 1)
#define len(a) ((int)(a).size())
mt19937 rnd(234);
const ll inf = 1e9;
#include <bits/extc++.h>
templ... | passed | 46_std.cpp |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int n;
cin >> n;
vector<long double> x(n + 1, 0), y(n + 1, 0);
for (int i = 1; i <= n; ++i)
{
cin >> x[i] >> y[i];
}
vector<long double> prex(n ... | passed | 67_std.cpp |
#include<bits/stdc++.h>
#ifdef LOCAL
#define debug(...) printf(__VA_ARGS__)
#define edebug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#define edebug(...)
#endif
#define int __int128
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define nrep(i, x, y) for(int i = x; i >= y; --i)
#define ll long long
#d... | passed | 72_std.cpp |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#incl... | passed | 84_std.cpp |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
bool grid[MAXN][MAXN];
int dist[MAXN][MAXN][4];
// R, U, L, D
int dirs[4][2]{{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
string cdirs = "RULD";
int n, q;
void dfs(int r, int c, int dir) {
if (dist[r][c][dir] != 0) {
if (dist[r][c][dir] == -1) {
... | passed | 98_std.cpp |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
#define popcnt __builtin_popcountll
const ll mod = 998244353;
const int INF = 1e9;
inline ll read(){
ll x=0, f=1; ch... | passed | 37_std.cpp |
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int max1 = 5000;
const int mod = 998244353;
int n, father[max1 + 5];
vector <int> son[max1 + 5];
int inv[max1 + 5], fac[max1 + 5], ifac[max1 + 5];
int siz[max1 + 5], inv_pi[max1 + 5];
vector <int> left_pi[max1 + 5], right_pi[max1 +... | passed | 49_std.cpp |
#include <bits/stdc++.h>
#define int long long
signed main()
{
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int n, k;
std::cin >> n >> k;
std::string s;
std::cin >> s;
int tmp = n;
while (tmp % 2 == 0 and k >= 1)
{
tmp /= 2;
--k;
// 暴力一次
std::stri... | passed | 61_std.cpp |
#include <bits/stdc++.h>
#define endl '\n'
#define int ll
using ll = long long;
typedef unsigned long long ull;
using namespace std;
void GordenGhost();
const ll mod = 998244353;
signed main() {
#ifdef Gorden
freopen("in.txt", "rt", stdin);
freopen("out.txt", "wt", stdout);
#endif
ios::sync_with_stdio(fal... | passed | 74_std.cpp |
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <cctype>
#include <set>
namespace uvu
{
#define LOCAL ____________DONT_DEFINE_ME____________
// #define ll long long
// #define inf 0x3f3f3f3f
#define int long long
#... | passed | 103_std.cpp |
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#incl... | passed | 34_std.cpp |
#include<bits/stdc++.h>
#define EL puts("Elaina")
typedef long long ll;
using namespace std;
const int maxn=1e3+3;
int n,m,q;double p,f[maxn][maxn];
inline void MyDearMoments(){
scanf("%d%d%d",&n,&m,&q),p=q;
f[1][1]=0;
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j){
if(i==1&&j==1)continue;
if(i==1)f[i][j]=f[i][j-1]+... | passed | 105_std.cpp |
#include<bits/stdc++.h>
using namespace std;
string s;
int t,n,k,ans,now;
string p="nanjing";
int check(int l,int r)
{
int sum=0;
now=0;
for(int i=l;i<=r-6;i++)
{
if( s[i]==p[0] )
{
int ok=1;
for(int j=0;j<7;j++)
{
if( s[i+j]!=p[j] )ok=0;
}
sum+=ok;
}
}
retu... | passed | 51_std.cpp |
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
const int mod=998244353;
using namespace std;
int n,fa[100001],dep[100001];
int hed[100001],net[200001],ver[200001],tot;
void add(int x,int y){
ver[++tot]=y;
net[tot]=hed[x];
hed[x]=tot;
}
long long d[100001],g[100001],sum[100001];
int sz[10000... | passed | 4_std.cpp |
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
const int maxn = 100000 + 5, maxlg = 18;
namespace PAM {
int trans[maxn][26];
int len[maxn], fail[maxn], fa[maxn], tot, last;
int dp[maxn];
void clear() {
for (int i = 1; i <= tot; i++) {
len[i] = fail[i] = fa[i] = 0;
memset(trans[i], 0, sizeof(... | passed | 53_std.cpp |
#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
long long pw[20], inv[4] = {0, 1, (P + 1) / 2, (P + 1) / 3};
long long sum(long long l, long long r) {
return (__int128)(l + r) * (r - l + 1) / 2 % P;
}
void get(long long x, vector< array<long long, 3> > &o, long long &l, long long &r) {
... | passed | 7_std.cpp |
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
constexpr int maxn = 500000 + 10;
int a[maxn];
struct node
{
int mn, tag = -1, add, cnt;
i64 sum;
} t[maxn << 2];
void build(int o, int l, int r)
{
if (l == r) return t[o].mn = t[o].sum = a[r], void();
int m... | passed | 23_std.cpp |
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef LOCAL
#include <bits/debug.h>
#else
#define dbg(...)
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--) {
int n, m;
ll k;
cin >> n >> k >> m;
... | passed | 90_std.cpp |
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define MP make_pair
#define pb push_back
using namespace std;
void solve() {
int n;
cin >> n;
n*=3;
vector <int> g;
vector <int> a(n), b(n);
vector <bool> mark(n);
for(int i = 0; i < n; i++) {
cin >>... | passed | 13_std.cpp |
#include "bits/stdc++.h"
using namespace std;
#define all(x) x.begin(),x.end()
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << " " << p.second; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename... | passed | 91_std.cpp |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pil pair<int, ll>
#define x first
#define y second
inline int read() {
int x = 0, f = 0; char ch = getchar();
while (!isdigit(ch)) f = ch == '-', ch = getchar();
while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getch... | passed | 39_std.cpp |
#include <bits/stdc++.h>
using namespace std;
#define N 200010
#define K 10
int n, k;
bool B[N][2][2];
int a[N], b[N], w[N];
int ans[K][K][2][2];
bool sol(string a, int p, int q)
{
stack<int>S;
/*
-1 -> '!'
-2 -> '='
-3 -> '&'
-4 -> '|'
-5 -> '^'
-6 -> '('
*... | passed | 101_std.cpp |
#include <bits/stdc++.h>
signed main()
{
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int n, m, x, y;
std::cin >> n >> m >> x >> y;
std::vector<int> a(n + 1), b(m + 1);
for (int i = 1; i <= n; ++i)
{
std::cin >> a[i];
}
for (int i = 1; i <= m; ++i)
{
std::ci... | passed | 66_std.cpp |
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=1e4,inf=1e9;
int n,m,pos,C[60][60],a[60];
vector<int> ans[60];
inline void dfs(int x,int k)
{
if(k>(pos+1)/2) return; if(k+(pos-x+1)<(pos+1)/2) return;
if(x>pos... | passed | 111_std.cpp |
#include <cstdint>
#include <ios>
#include <iostream>
#include <vector>
void solve() {
std::int32_t n;
std::int64_t p;
std::cin >> n >> p;
std::vector<std::int64_t> c(n);
for (auto& x : c) {
std::cin >> x;
}
for (std::int32_t i = 0; i < n; ++i) {
if (c[i] - 1 > (p - 1) ... | passed | 107_std.cpp |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int T, n, m, q, pre[maxn], nxt[maxn];
int dfn[maxn], low[maxn], tot, stk[maxn], instk[maxn], top, col[maxn], cnt;
long long lastans, sum[maxn];
vector<int> a[maxn], G[maxn];
void tarjan(int u) {
dfn[u] = low[u] = ++tot, stk[++top] = u, instk[u] ... | passed | 28_std.cpp |
#include <bits/stdc++.h>
using namespace std;
typedef long double LD;
const LD eps = 1e-11;
int sgn(LD x) { return x > eps ? 1 : (x < -eps ? -1 : 0); }
struct p2 {
LD x, y;
p2 operator+(const p2 &b) const { return {x + b.x, y + b.y}; }
p2 operator-(const p2 &b) const { return {x - b.x, y - b.y}; }
p2 operato... | passed | 15_std.cpp |
#include <bits/stdc++.h>
using namespace std;
int n, m;
int main(){
// freopen("t.out","w",stdout);
int T;
cin>>T;
while(T--){
cin>>n>>m;
if(n == 1 || m == 1){
puts("Yes");
if(n == 1 && m == 1){
cout<<"0\n0\n";
}
else if(n =... | passed | 80_std.cpp |
#include <bits/stdc++.h>
template <class T>
inline int qlog(T a) {
double x = a;
return ((*(long long*) & x) >> 52 & 2047) - 1023;
}
#define fopen LilyWhite
void fopen(const char *s) {
static char filename[32];
sprintf(filename, "%s.in", s);
freopen(filename, "r", stdin);
sprintf(filename, "%s.out",... | passed | 81_std.cpp |
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
using namespace std;
#include <initializer_list>
namespace nachia{
bool IsPrime(unsigned long long x) noexcept {
if(x <= 1) return false;
if(x % 2 == 0) return x == 2;
using u64 = u... | passed | 42_std.cpp |
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
typedef long long ll;
struct Node{
ll id;
ll score;
bool operator <(const Node &a)const{
if(a.score == score){
return id < a.id;
}
else{
return score > a.score;
}
}
}play[N];
int now;
map<pair<int, int>, bool> ed;
ll lv[N];
void solv... | passed | 9_std.cpp |
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define eb empl... | passed | 33_std.cpp |
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+12;
int ans,t,m,n,k,x,a,b;
bool vis[N];
set<int>edge[N];
map<pair<int,int>,int>mp;
struct node{
int sum,id,l;
}p[N];
int main()
{
cin>>t;
while(t--)
{
cin>>n>>m>>k;
int ma1=0,ma2=0;
ans=0;
for(int i=1;i<=k;i++)
{
p[i]={0,0,0}... | passed | 55_std.cpp |
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
using namespace std;
const int N = 2e5 + 100;
vector<int>v[N];
int h[N], ans[N];
void dfs(int x, int px=-1) {
if(px == -1) {
h[x] = 0;
}
else {
h[x] = h[px] + 1;
... | passed | 20_std.cpp |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int K = 8;
vector<vector<pair<int, array<int, K>>>> g;
vector<array<int, K>> all;
int who(const array<int, K> &v) {
return lower_bound(all.begin(), all.end(), v) - all.begin();
}
constexpr int A = 6561;
array<vector<array<int, K>>,A> ... | passed | 41_std.cpp |
#include <bits/stdc++.h>
using namespace std;
bool kmp(const vector<int>& text, const vector<int>& pattern) {
int m = pattern.size();
if (m == 0) return false;
vector<int> lps(m, 0);
int len = 0;
for (int i = 1; i < m;) {
if (pattern[i] == pattern[len]) {
len++;
lps[... | passed | 102_std.cpp |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
void D(int n, int k, int *p1, int *p2)
{
if (!n) return p1[0] = p2[0] = 0, void();
if (n == 1) return p1[0] = p2[1] = 0, p1[1] = p2[0] = 1, void();
int mid = 1 << (n - 1);
if (k < mid) D(n - 1, k, p1, p1 + mid);
else D(n - 1,... | passed | 56_std.cpp |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int n, m;
long long a[maxn];
struct node {
long long sum, zero, tag;
}t[maxn << 2];
inline void update(int d) {
t[d].sum = t[d << 1].sum & t[d << 1 | 1].sum;
t[d].zero = (t[d << 1].zero & t[d << 1 | 1].sum) | (t[d << 1].sum & t[d << 1 ... | passed | 25_std.cpp |
#include <bits/stdc++.h>
#define int long long
#define INF 0x3f3f3f3f
#define llINF 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(), x.end()
#define alll(x, t) x.begin() + t, x.end()
#define rall(x) x.rbegin(), x.rend()
#define ull unsigned long long
#define PII pair<int, int>
#define fi first
#define se second
#define pb ... | passed | 83_std.cpp |
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
typedef long long i64;
typedef pair<int, int> pii;
void solve() {
string s; cin >> s;
int n = s.length();
vector<pii> nxt(n + 2);
for(int i = n, nxtr = n + 1; i >= 0; i--) {
nxt[i].second = nxtr;... | passed | 44_std.cpp |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 6