This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| using i64 = long long; | |
| i64 dfs(i64 a, i64 b, i64 c) { | |
| i64 m = max({a, b, c}); | |
| if (m == a || m == c) return 3 * m; | |
| return max({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| int solve() { | |
| int n; | |
| string s, t; | |
| cin >> n >> s >> t; | |
| s = ' ' + s; | |
| t = ' ' + t; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| const int N = 510; | |
| int a[N][N], b[N][N]; | |
| signed main() { | |
| ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); | |
| int n, m; | |
| cin >> n >> m; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| using i64 = long long; | |
| const int N = 5010; | |
| int n, m, h[N], e[N], from[N], nxt[N], d[N], idx = 1; | |
| void add(int a, int b) { | |
| e[idx] = b, nxt[idx] = h[a], from[idx] = a, d[b]++, h[a] = idx++; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| using i64 = long long; | |
| void solve() { | |
| int n; | |
| cin >> n; | |
| vector<string> s(n); | |
| for (int i = 0; i < n; i++) cin >> s[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| #define pb push_back | |
| const int N = 2e5 + 10; | |
| int h[N], rm[N], sz[N], mxsz[N], idx = 2; | |
| struct Edge { | |
| int to, nxt; | |
| } e[N]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| using PII = pair<int, int>; | |
| #define pb push_back | |
| const int N = 6e5 + 10; | |
| int h[N], col[N], idx = 2; | |
| struct Edge { | |
| int to, nxt; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| using i64 = long long; | |
| const int N = 1e4 + 114; | |
| bitset<N> st; | |
| vector<int> primes; | |
| void sieve(int n) { | |
| for (int i = 2; i <= n; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import gcd, lcm | |
| def exCRT(x1: int, m1: int, x2: int, m2: int) -> tuple[int, int]: | |
| g = gcd(m1, m2) | |
| m = lcm(m1, m2) | |
| k0 = (x2 - x1) // g * pow(m1 // g, -1, m2 // g) % (m2 // g) | |
| return (k0 * m1 + x1) % m, m | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| using i64 = long long; | |
| void solve() { | |
| int n; | |
| cin >> n; | |
| vector<int> a(n+1); | |
| int mx = -1; |
NewerOlder