text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; const int N = 3e3 + 5; template <typename T> T _abs(T a) { return (a < 0) ? (-a) : (a); } int n, m; vector<int> cir; vector<int> G[N]; stack<int> S; bool vis[N], onc[N]; void dfs(int p, int fa) { if (vis[p]) { int cur; do { cur = S.top(); S.pop(); ...
#include <bits/stdc++.h> using namespace std; int N, lk[6005], nx[6005], head[3005], s[3005], d[3005], dfn[3005], tot, L, p[3005], q[3005], fa[3005], f[3005][3005]; bool b[3005]; void init() { scanf("%d", &N); auto add = [&](int u, int v, int t) { lk[t] = v, nx[t] = head[u], head[u] = t; }; for (int i =...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") using namespace std; const double inf = 1e121; const double eps = 1e-10; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long randint(long long l, long long r) { long long out = rng() % (r - l + ...
#include <bits/stdc++.h> using namespace std; int read() { char c = getchar(); long long x = 1, s = 0; while (c < '0' || c > '9') { if (c == '-') x = -1; c = getchar(); } while (c >= '0' && c <= '9') { s = s * 10 + c - '0'; c = getchar(); } return s * x; } const int N = 4000; int n, x, y, ...
#include <bits/stdc++.h> using namespace std; int n; vector<int> v[3030]; void init() { scanf("%d", &n); for (int i = 0; i < n; i++) { int ai, bi; scanf("%d%d", &ai, &bi); v[ai].push_back(bi); v[bi].push_back(ai); } } bool oncyc[3030], instk[3030]; int vst[3030], p[3030][14], dep[3030], stk[3030];...
#include <bits/stdc++.h> using namespace std; int read() { int a = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) { a = a * 10 + c - 48; c = getchar(); } return a; } const int _ = 3001; struct Edge { int end, upEd; } Ed[_ << 1]; int head[_], cntEd, N; void addEd(int a...
#include <bits/stdc++.h> using namespace std; const int N = 3e3 + 5; int read() { int x = 0, f = 1; char ch; while (!isdigit(ch = getchar())) (ch == '-') && (f = -f); for (x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48)) ; return x * f; } template <class T> T Abs(T a) { ...
#include <bits/stdc++.h> using namespace std; int n; vector<int> edge[3100]; int cir[3100], vi[3100], cirlen; int _lca[3100][3100], fa[3100], dep[3100]; void dfs2(int x) { dep[x] = dep[fa[x]] + 1; vi[x] = 1; for (typeof((edge[x]).begin()) y = (edge[x]).begin(); y != (edge[x]).end(); y++) if (*y != fa[x...
#include <bits/stdc++.h> using namespace std; inline int Get() { int res = 0, q = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') q = -1, ch = getchar(); while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar(); return res * q; } const doubl...
#include <bits/stdc++.h> using namespace std; const int maxn = 3005; int n, dep[maxn], point[maxn << 1], nextp[maxn << 1], head[maxn], cir[maxn], len, ecnt; void ins(int u, int v) { point[++ecnt] = v; nextp[ecnt] = head[u]; head[u] = ecnt; } int dfs(int x, int f) { dep[x] = dep[f] + 1; int i, to, tmp, res...
#include <bits/stdc++.h> using namespace std; struct edge { int v, next; } e[6005]; int etot = 0; int g[3005]; void ae(int u, int v) { e[etot].v = v; e[etot].next = g[u]; g[u] = etot++; } int n; double ans = 0.0; int pre[3005], vis[3005]; int cyc[3005], len = 0; int oncy[3005] = {0}; int dfs(int u) { vis[u] =...
#include <bits/stdc++.h> using namespace std; int head[5010]; int from[5010]; int to[100010]; int nex[100010]; int dep[5010]; int q[5010]; int cnt; int vis[5010]; int bel[5010]; int num[100010]; double ans; int tot; int x, y, n, m; int f[5010][17]; void add(int x, int y, int z) { nex[++tot] = head[x]; head[x] = tot...
#include <bits/stdc++.h> using namespace std; int n, mark[((int)3030)], pos[((int)3030)], dp[((int)12)][((int)3030)], dis[((int)3030)]; long double ans; vector<int> e[((int)3030)], now, cycle; bool dead[((int)3030)]; void dfs_cycle(int x, int par = 0) { mark[x] = 1; now.push_back(x); for (auto u : e[x]) { ...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, const U &b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, const U &b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c = getchar(), ...
#include <bits/stdc++.h> using namespace std; const int N = 3000 + 5; int n; int hd[N], to[N * 2], nxt[N * 2]; inline void add_se(int idx, int a, int b) { nxt[idx] = hd[a]; hd[a] = idx; to[idx] = b; } int sz_circ, circ[N], at_circ[N], stk[N], stkfr[N], b_stk; ; bool vis[N], incirc[N], e_incirc[N]; bool dfs_circ(i...
#include <bits/stdc++.h> namespace ringo { template <class T> inline void read(T &x) { x = 0; char c = getchar(); bool f = 0; while (!isdigit(c)) f ^= c == '-', c = getchar(); while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); if (f) x = -x; } template <class T> inline void print(T x) { if (x < 0) pu...
#include <bits/stdc++.h> using namespace std; vector<int> adj[3000]; bool visited[3000]; bool incycle[3000]; int find_cycle(int u, int p) { if (visited[u]) return u; visited[u] = true; for (int c : adj[u]) if (c != p) { int x = find_cycle(c, u); if (x != -1) { incycle[u] = true; re...
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T& num) { num = 0; bool f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = 0; ch = getchar(); } while (ch >= '0' && ch <= '9') { num = num * 10 + ch - '0'; ch = getchar(); } num =...
#include <bits/stdc++.h> using namespace std; struct graph { int nxt, to; } e[3005 << 1]; int g[3005], t[3005], d1[3005], d2[3005], n, cnt; bool ins[3005]; double ans; queue<int> q; inline int read() { int ret = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) { ret = (ret << 1...
#include <bits/stdc++.h> using namespace std; const int MAXN = 3005; int n; int deg[MAXN]; vector<int> edges[MAXN]; double ans = 0; int vis[MAXN]; int dist[MAXN], dist2[MAXN]; int cirsiz = 0; void dfs(int x) { vis[x] = 1; for (auto nex : edges[x]) if (!vis[nex]) { dist2[nex] = dist2[x] + 1; if (!dis...
#include <bits/stdc++.h> long long gi() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) f ^= ch == '-', ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return f ? x : -x; } std::mt19937 rnd(time(NULL)); template <class T> void cxk(T& a, T b) { a = a > b ? a : b...
#include <bits/stdc++.h> const int maxn = 3010; const int maxm = 6010; using namespace std; int ter[maxm], nxt[maxm], lnk[maxn], d[maxn]; int n, m, e, tot, opt[maxn], pos[maxn], dis[maxn], bel[maxn], fa[maxn][20]; bool cir[maxn], vis[maxn]; void add(int x, int y) { ter[++e] = y, nxt[e] = lnk[x], lnk[x] = e; ter[++e...
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 29, N = 5e5 + 50, M = 1e6 + 5; inline int read() { int f = 1, x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getc...
#include <bits/stdc++.h> using namespace std; const int N = 100010, M = 1000010, P = 1e9 + 7; const int inf = 0x3f3f3f3f; const int INF = 0xcfcfcfcf; const double eps = 1e-9, pi = asin(1) * 2; inline long long read(); inline int ADD(int a, int b) { return a + b >= P ? a + b - P : a + b; } inline int MINUS(int a, int b)...
#include <bits/stdc++.h> using namespace std; int vis[3010]; vector<int> ne[3010]; int n, siz; int du[3010]; queue<int> q; double ans; void dfs(int u, int siza, int sizb, int top) { if (du[u] == 2) sizb++; else siza++; vis[u] = top; if (sizb == siz) ans += 1.0 / (siza + 2); else if (sizb <= 2) ...
#include <bits/stdc++.h> using namespace std; void file(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } template <typename Tp> void read(Tp &x) { int fh = 1; char c = getchar(); x = 0; while (c > '9' || c < '0') { if (c == '-') { fh = -1; } ...
#include <bits/stdc++.h> using namespace std; template <class T1> void debug(T1 e) { cout << e << endl; } template <class T1, class T2> void debug(T1 e1, T2 e2) { cout << e1 << "\t" << e2 << endl; } template <class T1, class T2, class T3> void debug(T1 e1, T2 e2, T3 e3) { cout << e1 << "\t" << e2 << "\t" << e3 <<...
#include <bits/stdc++.h> using namespace std; struct road { int x, next; } r[3005 * 2]; int N, M; double ans; int fa[3005], flag; int st[3005], w, vis[3005], pr[3005]; int deep[3005], lca[3005][3005], rt[3005]; int loop[3005], num[3005], cnt; int stk[3005], top; int find(int x) { if (fa[x] == x) return x; return ...
#include <bits/stdc++.h> using namespace std; const int maxn = (int)3e3 + 1; int n, m, seq[maxn], idx[maxn], dep[maxn]; vector<int> e[maxn]; bool vis[maxn], ban[maxn]; bool pfs(int u) { vis[u] = 1; seq[m++] = u; for (auto &v : e[u]) if (vis[v]) { if (m > 1 && v == seq[m - 2]) continue; for (int i ...
#include <bits/stdc++.h> using namespace std; inline int getint() { static char c; while ((c = getchar()) < '0' || c > '9') ; int res = c - '0'; while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0'; return res; } const int MaxN = 3005; int n; int cir_l = 0; struct halfEdge { int v, w; h...
#include <bits/stdc++.h> using namespace std; const int N = 5010; int head[N], from[N], to[N << 2], nxt[N << 2], dep[N], q[N], vis[N], bel[N], num[N << 2], cnt; double ans; int tot, x, y, n, m; int f[N][25]; inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f...
#include <bits/stdc++.h> using namespace std; int szm[3100][3100]; int numd; int sizc; int totb; int hc; struct nodeb { int next; int v; }; nodeb szb[3100 << 1]; struct noded { bool inc; bool vis; int next; int ind; int top; }; noded szd[3100]; void adde(int from, int to) { totb++; szb[totb].v = to; ...
#include <bits/stdc++.h> using namespace std; const int N = 3 * 1e3 + 10; int v[N << 1]; int x[N << 1]; int ct; int al[N]; bool isr[N]; int n; int tot; int ed; int st; double ans; inline void add(int u, int V) { v[++ct] = V; x[ct] = al[u]; al[u] = ct; } struct bcj { int fa[N]; inline void ih() { for (int ...
#include <bits/stdc++.h> using namespace std; struct apple { int v, nxt; } edge[3011 * 4]; double ans; int n, len, indexx[3011], a[3011], cir[3011], belong[3011], fa[3011][20 + 1], tot, vist[3011], rt, deep[3011]; void addedge(int x, int y) { edge[++tot].v = y; edge[tot].nxt = indexx[x]; indexx[x] = tot; } ...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void chkmax(T& x, U y) { if (x < y) x = y; } template <typename T, typename U> inline void chkmin(T& x, U y) { if (y < x) x = y; } vector<int> V; double ans; const int MAXN = 3333; int T; int par[MAXN], vis[MAXN], dis[MAXN]; vect...
#include <bits/stdc++.h> using namespace std; inline int read() { bool f = true; register int x = 0; char ch; while (!isdigit(ch = getchar())) if (ch == '-') f = false; while (isdigit(ch)) { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return f ? x : -x; } double ans; int n, cnt, C, H...
#include <bits/stdc++.h> using namespace std; const int MAXN = 3005; vector<int> p[MAXN]; int n; double ans = 0; bool instack[MAXN]; int rd[MAXN]; int circle; int q[MAXN]; inline void TopSort() { for (int i = (0); i <= (int)n - 1; i++) if (rd[i] == 1) q[++q[0]] = i; for (int i = (1); i <= (int)q[0]; i++) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 3000; vector<int> g[maxn + 50]; queue<int> q; int d[maxn + 50], d1[maxn + 50]; bool vis[maxn + 50]; int x, y, n, l = 0; double ans = 0.0; void dfs(int k) { vis[k] = 1; for (int i = 0; i < g[k].size(); ++i) if (!vis[g[k][i]]) { d[g[k][i]] = d[k...
#include <bits/stdc++.h> using namespace std; int n, S[5010], dis1[5010], dis2[5010], Head[5010], Next[10010], Go[10010], Cnt = 0, Top = 0, Where[5010], Cycle = 0; bool Vis[5010]; double ans = 0.0; inline void addedge(int x, int y) { Go[++Cnt] = y; Next[Cnt] = Head[x]; Head[x] = Cnt; } void Find(int x, int be...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long double pi = acosl(-1); const long long infl = 1e17 + 100; const int inf = 1e9 + 100; const int nmax = 3000 + 10; const int MAXLG = log2(nmax) + 1; vector<int> g[nmax]; int depth[nmax]; int par[nmax]; int LCA[nmax][nmax]; int recc(int u, int v) ...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char p = getchar(); while (!isdigit(p)) { if (p == '-') f = -1; p = getchar(); } while (isdigit(p)) x = (x << 3) + (x << 1) + (p ^ 48), p = getchar(); return x * f; } const int maxn = 3e3 + 5; int n, head[maxn], ver[...
#include <bits/stdc++.h> using namespace std; int head[100005]; struct edge { int vet, next; } E[200005]; int i, j, k, n, m, s, t, tot, L; int top[100005]; int fa[100005]; int dep[100005]; int a[100005]; int dist[3005][3005]; double ans; int X, Y, all; int cyc[100005]; int getf(int x) { if (x != fa[x]) fa[x] = getf...
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } if (flag) x = -x; } using name...
#include <bits/stdc++.h> using namespace std; char s[100005]; int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<string, int> my; void check(char* s) { if (((s[0]) >= '0' && (s[0]) <= '9') && ((s[1]) >= '0' && (s[1]) <= '9') && ((s[3]) >= '0' && (s[3]) <= '9') && ((s[4]) >= '0' && (s[4]) <= '9') ...
#include <bits/stdc++.h> using namespace std; int occ[40][20][10]; bool isNumber(char c) { return (48 <= int(c) && int(c) <= 57); } int sti(string s) { int ans = 0; for (int i = 0; i < s.length(); i++) ans = ans * 10 + int(s[i]) - 48; return ans; } int date[20] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31...
#include <bits/stdc++.h> using namespace std; void gt(int &a, int b) { if (a < b) a = b; } string n2s(int a) { stringstream ss; ss << a; return ss.str(); } int days[]{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool isValidDate(string str) { int d, m, y; char ch; for (int i = 0; i <= 8; i++) { ...
#include <bits/stdc++.h> using namespace std; const int dayinmonth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int num(string s) { int res = 0; for (int i = 0, _a = (int(s.size())); i < _a; ++i) if (s[i] < '0' || s[i] > '9') return -1; else res = res * 10 + s[i] - '0'; return re...
#include <bits/stdc++.h> using namespace std; const string f = "dd-mm-yyyy"; int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { bool ff; string s, a; int da, mo, ye; map<string, int> mp; cin >> s; for (int i = 0; i <= s.size() - f.size(); i++) { a = s.substr(i, f.size()); ...
#include <bits/stdc++.h> using namespace std; string s; map<string, int> m; string ans; int bns = 0; int dd[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool type[10] = {0, 0, 1, 0, 0, 1, 0, 0, 0, 0}; bool check(string s) { for (int i = 0; i < 10; i++) { if (type[i]) { if (s[i] != '-') return ...
#include <bits/stdc++.h> using namespace std; inline int to_int(string s) { int x = 0; for (int i = 0; i < (int)s.size(); ++i) x *= 10, x += s[i] - '0'; return x; } char s[100005]; int mp[33][15][2020]; string tmp, mx; int d, mn, y, mxx = -1, n, m[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, ...
#include <bits/stdc++.h> using namespace std; string s; const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { cin >> s; map<string, int> mp; int v = INT_MIN; string ans; int len = s.length(); for (int i = 0; i + 9 < len; i++) { string x = s.substr(i, 10); int d = 0, m = ...
#include <bits/stdc++.h> using namespace std; map<string, int> m; string ans; int cnt = 0; int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { string s; cin >> s; for (int i = 0; i <= s.length() - 10; i++) { if (!(isdigit(s[i]) && isdigit(s[i + 1]) && s[i + 2] == '-' && is...
#include <bits/stdc++.h> using namespace std; long long n, m, ans; string str; map<string, long long> m1; long long solve() { cin >> str; n = (long long)str.size(); for (long long i = 0; i <= n - 10; ++i) { string s = str.substr(i, 10); vector<long long> v1; for (long long j = 0; j <= 9; ++j) { ...
#include <bits/stdc++.h> using namespace std; vector<int> day, month, year; map<pair<int, pair<int, int> >, int> mp; int main() { string s; cin >> s; int da[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; for (int i = 0; i < s.length(); i++) { if (s[i] == '-') { if (i < 2) continue; if...
#include <bits/stdc++.h> using namespace std; const int kd[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int cnt[42][42][42]; char s[555555]; int main() { cin >> s; int n = strlen(s); int mx = 0, ad = 0, am = 0, ay = 0; memset(cnt, 0, sizeof(cnt)); for (int i = 0; i + 9 < n; i++) { if (s[i + ...
#include <bits/stdc++.h> using namespace std; string a, b; unordered_map<string, int> mm; int day[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool check(string a) { for (int i = 0; i < a.size(); i++) { if (i == 2 || i == 5) { if (a[i] != '-') { return false; } } else { ...
#include <bits/stdc++.h> using namespace std; int ji[4][15][35]; int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; inline bool judge(int day, int month, int year) { if ((year >= 2013 && year <= 2015) == 0) return false; if ((month >= 1 && month <= 12) == 0) return false; if ((day > 0 && day <= mon[...
#include <bits/stdc++.h> int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; const double PI = acos(-1), EPS = 1e-7; const int OO = 0x3f3f3f3f, N = 1e5 + 5, mod = 1e9 + 7; using namespace std; long long gcd(long long x, long long y) { return (!y) ? x : gcd(y, x % y); } long long lcm(long lon...
#include <bits/stdc++.h> using namespace std; double const eps = 1e-6; const int inf = 0x3fffffff; const int size = 100000 + 5; int sz; map<string, int> cnt; int day[13] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool valid(int y, int m, int d) { if (y < 2013 || y > 2015) return false; if (m < 1 || m >...
#include <bits/stdc++.h> using namespace std; struct Date { int d, m, y; }; bool operator<(Date a, Date b) { return make_pair(make_pair(a.d, a.m), a.y) < make_pair(make_pair(b.d, b.m), b.y); } int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string s; bool cor_date(int i) { for (int j = 0...
#include <bits/stdc++.h> using namespace std; const long long OO = 1e8; string CF[] = {"NO", "YES"}; bool isDigit(string S) { for (int i = 0; i < (int)((int)((S).size())); ++i) { if (S[i] < '0' || S[i] > '9') return false; } return true; } bool Valid(string M) { if (M == "01" || M == "03" || M == "05" || M ...
#include <bits/stdc++.h> using namespace std; int Day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int maxx = -1; int main() { string s, ans; cin >> s; map<string, int> mp; for (int i = 0; i < (int)s.size() - 9; i++) { string t = s.substr(i, 10); int year = (t[9] - 48) + (t[8] - 48...
#include <bits/stdc++.h> using namespace std; int n; long long table[40][40]; long long solve(int nodes, int h) { if (nodes == 0) { return 1LL; } if (h == 0) { return 0; } long long &ret = table[nodes][h]; if (ret != -1) return ret; ret = 0; for (int i = 0; i < nodes; ++i) { ret += solve(i, ...
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const double EPS = 1e-9, INF = 1e12; string in; int day(int y, int m) { int d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; return d[m] + (y % 4 == 0); } int main() { cin >> in; map<string, int> cnt; for (int i = 0; i < (int)in...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:16777216") using namespace std; vector<int> mods = {1000000007, 1000000009, 998244353}; const double pi = acos(-1.0); const int inf = 0x3f3f3f3f; const int maxn = 200005; const int mod = mods[0]; const int day[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,...
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { if (y == 0) return x; else return gcd(y, x % y); } int main() { long long mon[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string s, ans; cin >> s; long long ma = 0; for (long long i = 2013; i < 2016...
#include <bits/stdc++.h> using namespace std; int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool check(string in) { if (in[2] != '-' || in[5] != '-') return false; int d = 0, m = 0, y = 0; for (int ctr1 = 0; ctr1 < 10; ctr1++) { if (ctr1 == 2) { d = y; y = 0; continue; ...
#include <bits/stdc++.h> using namespace std; int main() { int a[13] = {0}; a[1] = 31; a[2] = 28; a[3] = 31; a[4] = 30; a[5] = 31; a[6] = 30; a[7] = 31; a[8] = 31; a[9] = 30; a[10] = 31; a[11] = 30; a[12] = 31; int b[3][13][40]; for (int i = 0; i < 3; i++) { for (int j = 0; j <= 12; j+...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<string> A; for (int I = 0; I < s.length() - 9; I += 1) { string sub = s.substr(I, 10); bool ValidDM = false; int Day = 0; if (sub[0] == '0') { Day = sub[1] - '0'; } else Day = (sub[0] - '0') * 1...
#include <bits/stdc++.h> using namespace std; char str[123456]; char it[123]; char day[13][5] = {"31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"}; map<string, int> m; map<string, int>::iterator ut; int main() { scanf("%s", str); int len = strlen(str); m.clear(); for (in...
#include <bits/stdc++.h> using namespace std; map<string, int> mm; const int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool isnum(char a) { if (a < '0' || a > '9') return false; return true; } bool judge(string a) { if (!(isnum(a[0]) && isnum(a[1]) && isnum(a[3]) && isnum(a[4]) && is...
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int main() { string str, a; while (cin >> str) { int k = 0, t = 0; int sh[100001], maxx = 0, l; string ss[100001]; memset(sh, 0, sizeof(sh)); for (int i = 0; i < str.length(); i++) { int flag = 0; a = str.substr(i, 10...
#include <bits/stdc++.h> using namespace std; void prv(vector<int> v) { int n = v.size(); for (int i = 0; i < n; i++) cout << v[i] << " "; } void swap(long long int &a, long long int &b) { int tm = a; a = b; b = tm; } bool comp(const pair<int, int> &p1, const pair<int, int> &p2) { if (p1.first > p2.first) ...
#include <bits/stdc++.h> using namespace std; string s; map<string, int> a; int num_days[20] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { int ma = -10; cin >> s; string pointer; for (int i = 0; i < s.size(); ++i) { string f; f.clear(); if (isdigit(s[i]) && isdigit(s[i + 1]) &&...
#include <bits/stdc++.h> using namespace std; int Days(int Month) { if (Month == 2) return 28; if (Month == 4 || Month == 6 || Month == 9 || Month == 11) return 30; return 31; } int Calc(string S) { if (S[2] != '-' || S[5] != '-') return -1; for (int i = 0; i < 10; i++) { if (i == 2 || i == 5) continue; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e9; map<string, int> my_map; int m_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { string inp; cin >> inp; for (int i = 0; i < inp.size(); i++) { string buff = inp.substr(i, 10); bool flag = false; if (buff[2] != '...
#include <bits/stdc++.h> using namespace std; long long int biexp(long long int a, long long int b) { long long int res = 1; while (b) { if (b % 2) res = res * a; a = a * a; b = b / 2; } return res; } int main() { int t = 1; while (t--) { string s; cin >> s; string r; long long i...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T = 1; while (T--) { map<string, int> mp; string s; cin >> s; int n = int((s).size()); for (int i = 0; i < n - 9; i++) { if (isdigit(s[i]) && s[i + 2] == '-' && s...
#include <bits/stdc++.h> using namespace std; char s[100005]; char tmp[11]; int yy, dd, mm; int _map[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int num; char result[100005][11]; int resultnum[100005]; int check_dd_mm() { if (_map[mm] >= dd) return 1; return 0; } int add(int point) { for (int i = 9...
#include <bits/stdc++.h> using namespace std; int main() { string s, ans; char t[11]; cin >> s; int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int len = 0, day = 0, mon = 0, year = 0, flag = 0, cnt, max = 0; len = s.length(); for (year = 2013; year <= 2015; year++) { for (mon = 1; mo...
#include <bits/stdc++.h> char str[100005]; int cnt[40][20][4]; bool format[10] = {0, 0, 1, 0, 0, 1, 0, 0, 0, 0}; int dayofmonth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { scanf("%s", str); int n = strlen(str); for (int i = 2; i <= n - 8; i++) { int st = i - 2; bool flag = 0; ...
#include <bits/stdc++.h> char str[100010]; int times[40][15][5]; int monthmaxdays[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool isdigt[11] = {1, 1, 0, 1, 1, 0, 1, 1, 1, 1}; void print(int dd, int mm, int yyyy) { if (dd < 10) printf("0%d-", dd); else printf("%d-", dd); if (mm < 10) pr...
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; const double eps = 1e-9; const int mod = 1000007; const int inf = 0x7fffffff; const int maxlog = 33; template <class Int> inline int size(const Int &a) { return (int)a.size(); } map<string, int> mapp; const int MONTH_DAYS[] = {0, 31, 28, 31, 30, 31,...
#include <bits/stdc++.h> using namespace std; template <class X> class vec { public: X x, y; vec<X>(X a = 0, X b = 0) { x = a, y = b; } X dis(vec a) { return (x - a.x) * (x - a.x) + (y - a.y) * (y - a.y); } vec<X> operator-(vec<X> b) { return vec<X>(x - b.x, y - b.y); } X operator*(vec<X> b) { return x * b.y...
#include <bits/stdc++.h> using namespace std; string s; map<string, int> m; string ans; int bns = 0; int dd[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool check(string s) { string ss; ss = s.substr(5, 5); if (ss != "-2013" && ss != "-2014" && ss != "-2015") return false; if (s[2] != '-') return...
#include <bits/stdc++.h> using namespace std; int w[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string s; int getint(string p) { int res = 0; for (int j = 0; j < p.length(); j++) if (p[j] == '-') return -1; else { res = res * 10 + (p[j] - '0'); } return res; } map<string, in...
#include <bits/stdc++.h> using namespace std; char s[100006], wc[13]; bool ok[10]; long D[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<string, long> MAP; long anss; string ans, now; int main() { std::ios::sync_with_stdio(false); long i, j, d, m, y; cin >> s; ok[2] = ok[5] = 1; for (i = 0; s[...
#include <bits/stdc++.h> using namespace std; const int maxN = 1000 + 5; const int mod = 1000 * 1000 * 1000 + 7; int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int num(string s) { int res = 0; for (int i = 0; i < ((int)(s).size()); i++) { if (s[i] < '0' || s[i] > '9') return -1; res = res * ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int arr[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char str[maxn]; map<string, int> mp; struct CmpByValue { bool operator()(const pair<string, int>& lhs, const pair<string, int>& rhs) { return lhs.second > rhs.second; } }; ...
#include <bits/stdc++.h> using namespace std; bool tep(pair<string, int> a, pair<string, int> b) { return a.second > b.second; } bool f(string s) { for (int i = 0; i < 10; i++) { if ((i == 2 || i == 5) && s[i] != '-') return 0; if ((i != 2 && i != 5) && s[i] == '-') return 0; } if (s.substr(6) != "2013"...
#include <bits/stdc++.h> using namespace std; map<int, int> m; map<int, int>::iterator it; int mesec(int m) { if (m == 1) return 31; else if (m == 2) return 28; else if (m == 3) return 31; else if (m == 4) return 30; else if (m == 5) return 31; else if (m == 6) return 30; else if (...
#include <bits/stdc++.h> using namespace std; const int d[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int o[31][12][3]; bool isDigit(char c) { return '0' <= c && c <= '9'; } int toInt(char c) { return c - '0'; } int main() { char t[100001]; scanf("%s", t); int l = strlen(t); for (int i = 0; i <= l -...
#include <bits/stdc++.h> using namespace std; const int mod = int(1e9 + 7); const double PI = acos(-1.0); int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int func(string second) { int i, sum = 0; for (i = 0; i < second.length(); i++) sum = sum * 10 + (int)second[i] - 48; return sum; } int ms, k, ...
#include <bits/stdc++.h> using namespace std; struct Node { int y, m, d; Node(int y = 0, int m = 0, int d = 0) : y(y), m(m), d(d) {} bool operator<(const Node &b) const { if (y != b.y) return y < b.y; if (m != b.m) return m < b.m; return d < b.d; } void out() { printf("%02d-%02d-%04d\n", d, m, y);...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; const int xx = (int)1e6 + 1; bool sortinrev(const pair<long long int, long long int> &a, const pair<long long int, long long int> &b) { return (a.first > b.first); } long long int A[1000000]; long long int B[1000000]; map<long ...
#include <bits/stdc++.h> using namespace std; template <class T, class L> bool smax(T &x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> bool smin(T &x, L y) { return y < x ? (x = y, 1) : 0; } const int maxn = 1e5 + 17; char s[maxn]; int n, mx[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,...
#include <bits/stdc++.h> char str[100001]; int cou[32][13][2020]; int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool isnum(char c) { if (c >= '0' && c <= '9') return true; return false; } bool isleap(int year) { if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return true; return...
#include <bits/stdc++.h> using namespace std; map<string, int> mp; string s; int main() { map<string, string> month; month["01"] = "31"; month["02"] = "28"; month["03"] = "31"; month["04"] = "30"; month["05"] = "31"; month["06"] = "30"; month["07"] = "31"; month["08"] = "31"; month["09"] = "30"; m...
#include <bits/stdc++.h> using namespace std; long long int M = 1000000007; long long int gcd(long long int a, long long int b) { return (b == 0) ? a : gcd(b, a % b); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t = 1; while (t--) { map<string, string>...
#include <bits/stdc++.h> using namespace std; long long power(long long b, long long e, long long m) { if (e == 0) return 1; if (e % 2) return b * power(b * b % m, (e - 1) / 2, m) % m; else return power(b * b % m, e / 2, m); } long long power(long long b, long long e) { if (e == 0) return 1; if (e % 2...