text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
long long size = (r - l) + 1;
l--;
r--;
long long curr = 0;
long long startVer = 1;
while (... |
#include <bits/stdc++.h>
using namespace std;
long long n, l, r, curr;
void solve(long long depth = 0) {
if (depth == n) {
if ((curr <= r)) cout << 1 << " ";
return;
}
if ((curr + 2 * (n - depth - 1) - 1) < l) {
curr += 2 * (n - depth - 1);
solve(depth + 1);
return;
} else if ((curr > r)) {
... |
#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
const int xn = -20 + 10;
const int xm = 2e1 + 10;
const int SQ = 450;
const int sq = 1e3 + 10;
const int inf = 1e9 + 10;
const long long INF = 1e18 + 10;
long long power(long long a, long long b) {
return (!b ? 1
: (b & 1 ? a * p... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
long long idx = 1;
bool p = false;
bool end = false;
for (long long i = 1; i <= n - 1; i++) {
... |
#include <bits/stdc++.h>
using namespace std;
const double PI = 4 * atan(1);
const long long INF = 1e18;
const int MX = 100001;
int T, n;
long long l, r;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> T;
while (T--) {
cin >> n >> l >> r;
long long first_elt = 1;
long long num_visited = 0;
... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
template <typename T>
bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
} els... |
#include <bits/stdc++.h>
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf, obuf[1 << 23], *O = obuf;
inline int read() {
int x = 0, sign = 0;
char s = getchar();
while (!isdigit(s)) sign |= s == '-', s = getchar();
while (isdigit(s)) x = (x << 1) + (x << 3) + (s - '0'), s = getchar();
return sign ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void trace(const char* name, T&& arg1) {
cout << name << " : " << arg1 << endl;
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cout.write(names, comm... |
#include <bits/stdc++.h>
using namespace std;
int t, n, i;
long long l, r;
void afis(int n, int i, int l, int r) {
int val = n - i;
for (int j = l; j <= r; j++) {
if (j & 1)
cout << val << ' ';
else
cout << val + (j / 2) << ' ';
}
return;
}
int main() {
cin >> t;
for (; t; t--) {
cin... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
int t;
long long n, L, R;
long long a[500500], p[500500];
void solve() {
cin >> n >> L >> R;
a[1] = 2 * n - 2;
for (int i = 2; i <= n - 1; ++i) a[i] = a[i - 1] - 2;
a[n] = 1;
for (int i = 1; i <= n; ++i) p[i] = p[i - 1] + ... |
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tcase;
cin >> tcase;
for (int tc = 1; tc <= tcase; tc++) {
long long ... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
long long t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
if (n == 1) {
cout << "1" << endl;
continue;
}
long long x = 2 * (n ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(T t) {
return t < 0 ? -t : t;
}
const long long modn = 1000000007;
inline long long mod(long long x) { return x % modn; }
const int MAXN = 212345;
int n, m, k;
long long l, r;
int s[MAXN];
vector<int> ans;
long long stp;
void add(int x) ... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
const long long MOD = 998244353;
long long gcd(long long a, long long b) {
if (a < b) {
s... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
long long gcd(long long a, long long b) { re... |
#include <bits/stdc++.h>
using namespace std;
void upgrade() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
}
int main() {
upgrade();
int tc;
cin >> tc;
while (tc--) {
long long n, l, r;
cin >> n >> l >> r;
long long add = 2 * n - 2, cnt = 0, h = 1;
while (add != 0 && cnt +... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5, K = 11, M = N * 4;
const long long MOD = 998244353, oo = 1e9, OO = 1e18, mod = MOD;
const double pi = acos(-1), eps = 1e-17;
long long di[] = {0, 0, 1, -1};
long long dj[] = {1, -1, 0, 0};
int32_t main() {
ios_base::sync_with_stdio(false);
c... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6 + 100;
const int mod = (int)1e9 + 7;
void solve() {
long long n, l, r;
scanf("%lld%lld%lld", &n, &l, &r);
long long pos = -1, pre = 0;
for (auto i = (1); i <= (n); ++i) {
long long now = (n - i) * 2;
if (now == 0) now = 1;
if (p... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
ifstream fin("input.txt");
ofstream fout("output.txt");
long long fast_exp(long long base, long long exp) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1) res = (res * base) % 1000000007;
base = (base * base) % 1000000007;
exp /=... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
ll l, r;
cin >> l >> r;
ll idx = 1;
bool done = false;
for (int start = 1; start <= n; start++) {
if (idx ... |
#include <bits/stdc++.h>
using namespace std;
long long next() {
long long x;
cin >> x;
return x;
}
const int maxn = 2e5 + 2, intf = 1e9;
const long long inf = 2e18, mod = 1e9;
const long double eps = 1e-6;
long long n;
void _print(long long bucket_id, long long l, long long r) {
if (l > r) return;
if (bucket... |
#include <bits/stdc++.h>
using namespace std;
long long t, n, i, j, k, x, y, z, l, r, mid, q, m, ans, s;
vector<int> v[200005];
long long bs(long long l, long long r, long long z) {
long long ans = -1;
while (l <= r) {
mid = (l + r) >> 1;
if ((n - 1 + n - mid) * (mid) >= z) {
ans = mid;
r = mid ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t, i, j;
long long n, l, r, pos;
cin >> t;
while (t--) {
cin >> n >> l >> r;
pos = 1;
for (i = 1; i < n && pos < l; i++) {
pos += 2 * (n - i);
if (pos > l) {
pos -= 2 * (n... |
#include <bits/stdc++.h>
using namespace std;
long long n, t, l, r, start, star, have;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--) {
cin >> n >> l >> r;
have = 0;
star = start = n + 1;
for (long long i = 1; i <= n; i++)
if (2LL * n * i - i * ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int t;
cin >> t;
while (t--) {
long long int n, l, r;
cin >> n >> l >> r;
long long int count = 0;
long long int i = 1;
while (i < n) {
if (count + (2 * (n - i... |
#include <bits/stdc++.h>
const double PI =
3.141592653589793238462643383279502884197169399375105820974944;
using namespace std;
long long ModExp(long long x, long long y, long long m) {
long long res = 1;
x = x % m;
while (y > 0) {
if (y & 1) res = (res * x) % m;
y = y >> 1;
x = (x * x) % m;
}
... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17 + 9;
long long n, l, r;
void calc(long long ly, long long faltl, long long faltr) {
if (ly == n) {
r = 1;
} else if (faltl >= 2 * n - ly * 2) {
calc(ly + 1, faltl - 2 * n + ly * 2, faltr);
} else {
long long ind = ly + 1;
lon... |
#include <bits/stdc++.h>
using namespace std;
long long int power_mod(long long int a, long long int x) {
if (x == 0) return 1;
long long int y = power_mod(a, x / 2);
long long int ans = (y * y) % 1000000007;
if (x % 2) ans = (ans * a) % 1000000007;
return ans;
}
long long int inv(long long int a) { return po... |
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
register char c = ' ';
register long long v = 0, x = 1;
while ((c < '0') || (c > '9')) {
if (c == '-') x = -1;
c = getchar();
}
while ((c >= '0') && (c <= '9')) {
v = (v << 1) + (v << 3) + (c ^ 48);
c = getchar();
}
re... |
#include <bits/stdc++.h>
using namespace std;
int gcdExtended(int a, int b, int *x, int *y) {
if (a == 0) {
*x = 0, *y = 1;
return b;
}
int x1, y1;
int gcd = gcdExtended(b % a, a, &x1, &y1);
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
long long int modInverse(int a, int m) {
int x, y;
int g... |
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 9;
long long arr[SIZE];
int main() {
int t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
long long x = 2 * (n - 1);
arr[1] = x;
for (int i = 2; i < n; i++) {
x -= 2;
arr[i] = arr[i - 1] + x;
... |
#include <bits/stdc++.h>
using namespace std;
int T;
long long N;
long long L, R;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> T;
for (long long t = 0; t < T; t++) {
cin >> N >> L >> R;
if (L == N * (N - 1) + 1 && L == R) {
cout << "1\n";
continue;
}
long long ini = ... |
#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long md = 1000000007LL) {
long long res = 1;
x %= md;
while (y > 0) {
if (y & 1) res = (res * x) % md;
x *= x;
if (x >= md) x %= md;
y >>= 1;
}
return res;
}
signed main() {
ios_base::sync_with_stdio... |
#include <bits/stdc++.h>
using namespace std;
using namespace std;
inline int qpow(int b, int e, int m = 998244353) {
int a = 1;
for (; e; e >>= 1, b = (long long)b * b % m)
if (e & 1) a = (long long)a * b % m;
return a;
}
int n, m, q, k;
int a[300005], b[300005], c[300005];
const int pp[11] = {2, 3, 5, 7, 11... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int t = 1;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
bool f = 0;
if (r == (n * (n - 1) + 1)) {
r--;
f = 1;
}
long long ans1 = (n - 1) * 2;
long long sum = ans1, pos = ... |
#include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b) {
if (a >= b)
return a;
else
return b;
}
long long int min(long long int a, long long int b) {
if (a <= b)
return a;
else
return b;
}
void solve() {
long long int n, l, r;
cin >> n >> l >> r;
... |
#include <bits/stdc++.h>
using namespace std;
long long t, n, l, r;
void stampa(int x, int y) {
if (r == 0) return;
cout << x << " ";
r--;
if (x == n && y >= n) return;
int succ;
if (y > x) {
succ = x + (y == n);
} else {
if (x == n) {
succ = y + 1;
} else {
succ = x + 1;
}
}... |
#include <bits/stdc++.h>
using namespace std;
long long n;
void prnt(long long a, long long b, long long cnt) {
if (cnt) printf("%d ", a);
if (cnt < 2) return;
printf("%d ", b);
if (b != n)
prnt(a, b + 1, cnt - 2);
else if (a != n - 1)
prnt(a + 1, a + 2, cnt - 2);
else if (cnt > 2)
printf("1");
... |
#include <bits/stdc++.h>
using namespace std;
void file() {}
signed main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
;
long long t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
vector<long long> a;
long long cnt = 0, flag = 0;
for (long long i = 1; i <= n &&... |
#include <bits/stdc++.h>
using namespace std;
int T, n;
long long l, r;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> T;
while (T > 0) {
--T;
cin >> n >> l >> r;
long long s = 0;
for (int i = 1; i <= n; ++i) {
long long t = s + 1ll * 2 * (n - i);
... |
#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
long long solve(long long x, long long n) {
long long ind = lower_bound(arr + 1, arr + n, x) - arr;
x -= arr[ind - 1];
if (x & 1) return ind;
return x / 2 + ind;
}
int main() {
long long t;
cin >> t;
while (t--) {
long long n, l, r;
... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 500005;
const long long M = 1000000007;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
vector<long long> v;
v.push_back(1);
for (long long i = 1; i < n; i++) {
v.push_back(2 * i);
... |
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int MAXN = 0;
const int MAXK = 0;
void solve() {
long long n, l, r;
cin >> n >> l >> r;
long long sum = 0;
f... |
#include <bits/stdc++.h>
using namespace std;
void fun(long long start, long long end, long long l, long long r) {
long long n = end - start + 1;
for (long long i = max(1ll, l); i <= min(2 * (n - 1), r); i++) {
if (i % 2 == 0) {
cout << start + i / 2 << " ";
} else {
cout << start << " ";
}
... |
#include <bits/stdc++.h>
using namespace std;
void _print(long long int t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(long long unsigned t) { cerr << t... |
#include <bits/stdc++.h>
using namespace std;
void print_pattern(long long row, long long col, long long count,
long long elements) {
if (elements == 0) {
cout << 1 << " ";
return;
}
long long x = row;
long long next_x = row + 1;
long long j = 0;
bool flag = 1;
while (j < elemen... |
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
void clock_out() {
cerr << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
}
void fileio() {
freopen("/home/dwai/Desktop/cp/input.txt", "r", stdin);
freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
freopen... |
#include <bits/stdc++.h>
using namespace std;
long long z = 998244353;
long long gcd(long long a, long long b) {
if (a == 0) return b;
if (b == 0) return a;
return gcd(b, a % b);
}
long long power(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1) {
res = (res * a) % z;
b--;... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)2e9;
const long long inf = (long long)2e18;
const long double eps = (long double)1e-8;
const long long mod = (long long)1e9 + 7;
const long long MAXN = (long long)1e5 + 1;
const long long MAXC = (long long)1e6 + 1;
const long long MAXE = (lo... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
ifstream fin("input.txt");
ofstream fout("output.txt");
long long fast_exp(long long base, long long exp) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1) res = (res * base) % 1000000007;
base = (base * base) % 1000000007;
exp /=... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n;
long long l, r;
long long i;
cin >> n >> l >> r;
long long temp = l;
long long b = 1;
while (temp > 2 * (n - b) && b < n) {
temp = temp - 2 * (n - b);
b++;
}
for (... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t, i, n, cnt, od, l, r, ev, g;
cin >> t;
while (t--) {
cin >> n >> l >> r;
g = 0;
if (r == (n * (n - 1)) + 1) {
g = 500;
}
i = 0;
while (i <= n - 1) {
if (2 * n * (i) - (i) * (i + 1) < l) {
i++;
... |
#include <bits/stdc++.h>
using namespace std;
const int mods = 998244353;
const int maxn = 1e5 + 10;
const int N = 1e5 + 10;
const int E = 2e5 + 10;
long long n, l, r;
long long k[maxn];
vector<int> ans;
int main() {
int T;
cin >> T;
while (T--) {
cin >> n >> l >> r;
k[1] = 1;
for (int i = 2; i <= (n)... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const int LM = 3e5 + 4;
ll N;
ll L, R;
ll part[LM];
int main() {
int T;
scanf("%d", &T);
while (T--) {
scanf("%lld%lld%lld", &N, &L, &R);
bool e = 0;
if (R == N * (N - 1) + 1) {
e = 1;
R--;
}
... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, MAX = 1e5 + 5;
long long powN(long long a, long long p) {
if (p == 0) return 1;
long long z = powN(a, p / 2);
z = (z * z) % MOD;
if (p % 2) z = (z * a) % MOD;
return z;
}
vector<bool> is_prime(MAX + 1, true);
void Sieve() {
is_prime[0] =... |
#include <bits/stdc++.h>
using namespace std;
struct Edge {
long long to, dis, next, cost;
} edge[24050];
long long num = -1;
bool vis[10010];
long long mincost;
long long pre[10010], head[10010], cost[10010], last[10010], flow[10010], n, k,
a[110], b[110], s, t, maxflow;
long long to[110];
void add(long long f, ... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
void read(int &val) {
int x = 0;
int bz = 1;
char c;
for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
;
if (c == '-') {
bz = -1;
c = getchar();
}
for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
int solve() {
int n, k;
cin >> n >> k;
vector<pair<pair<int, int>, int>> arr(n);
for (int i = 0; i < n; i++)
cin >> arr[i].first.second >> arr[i].first.first, arr[i].second = i + 1;
sort(arr.begin(), arr.end());
vector<int> a(n), b(n);
... |
#include <bits/stdc++.h>
template <typename T>
bool ckmax(T& a, T b) {
return a < b ? a = b, 1 : 0;
}
template <typename T>
bool ckmin(T& a, T b) {
return b < a ? a = b, 1 : 0;
}
const int MN = 80;
int N, K, T, dp[MN][MN], ans;
bool u[MN], pr[MN][MN];
struct minion {
public:
int a, b, id;
void in() { scanf("%d... |
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 80;
const int INF = 1000000009;
struct ban {
int i;
int a, b;
};
bool operator<(const ban& t1, const ban& t2) { return t1.b < t2.b; }
int n, k;
ban t[N];
int dp[N][N];
... |
#include <bits/stdc++.h>
using namespace std;
int dp[76][76];
bool taken[76][76];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t, n, m;
cin >> t;
while (t--) {
cin >> n >> m;
vector<pair<pair<int, int>, int>> data(n);
for (int i = 0; i < n; ++i) {
cin >> data[i].first.second >>... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void r1(T &x) {
x = 0;
char c(getchar());
int f(1);
for (; c < '0' || c > '9'; c = getchar())
if (c == '-') f = -1;
for (; '0' <= c && c <= '9'; c = getchar()) x = (x * 10) + (c ^ 48);
x *= f;
}
template <typename T, typename... Args>
i... |
#include <bits/stdc++.h>
using namespace std;
class Debugger {
public:
template <typename T>
Debugger &operator<<(const T &v) {
cerr << v;
return *this;
}
~Debugger() { cerr << endl; }
};
template <typename T1, typename T2>
inline ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
return os <<... |
#include <bits/stdc++.h>
#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln = '\n';
istrea... |
#include <bits/stdc++.h>
using namespace std;
using li = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using matr = vector<vi>;
const int INF = 1e9 + 13;
vector<int> hungary(vector<vector<int>> a) {
int n = a.size() - 1;
int m = n;
vector<int> u(n + 1), v(m + 1), p(m + 1),... |
#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
char ch = getchar();
x = 0;
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
}
const long long N = 77;
long long n, k, f[N][N], g[N][N];
pair<long long, pair<long long, long long> > a[N];
vector... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
x = 0;
int f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
x *= f;
}
inline void write(int x) {... |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename S>
inline void chkmin(T &a, const S &b) {
a = a < b ? a : b;
}
template <typename T, typename S>
inline void chkmax(T &a, const S &b) {
a = a > b ? a : b;
}
const int MAXN = 80;
struct Data {
int a, b, id;
} dat[MAXN];
int f[MAXN][MAXN],... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vc<vc<T>>;
template <class T>
void mkuni(vector<T>& v) {
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
}
template <class T>
void print(T x, int suc = 1) {
cout << x;
if... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return f == 1 ? x : -x;
}
inline v... |
#include <bits/stdc++.h>
using namespace std;
pair<pair<int, int>, int> ba[102];
int g[102][102], dp[102][102];
int ans[102];
vector<int> ansvec;
bool compba(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
if (a.first.first != b.first.first) return a.first.first < b.first.first;
return a.first.second < ... |
#include <bits/stdc++.h>
template <typename T>
bool ckmax(T& a, T b) {
return a < b ? a = b, 1 : 0;
}
template <typename T>
bool ckmin(T& a, T b) {
return b < a ? a = b, 1 : 0;
}
const int MN = 80;
int N, RK, T, dp[MN][MN], ans;
bool u[MN], pr[MN][MN];
struct minion {
public:
int a, b, id;
void in() { scanf("%... |
#include <bits/stdc++.h>
using namespace std;
inline int add(int _a, int _b) {
if (_a < 0) {
_a += 1000000007;
}
if (_b < 0) {
_b += 1000000007;
}
if (_a + _b >= 1000000007) {
return _a + _b - 1000000007;
}
return _a + _b;
}
inline int mul(int _a, int _b) {
if (_a < 0) {
_a += 1000000007... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a(n), b(n);
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
}
vector<vector<long long>> dp(n + 1, vector<long long>(k + 2, 0));
vector<vector<int>> p(n + 1, vector<int>(k + 2));
vector<int> id(n);
... |
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T>
T sqr(T a) {
return a * a;
}
template <typename T>
int sign(T a) {
if (a == 0) return 0;
return (a > 0 ? 1 : -1);
}
template <typename T>
bool uax(T& a,... |
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
return os << "(" << x.first << "," << x.second << ")";
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int n, k;
scanf("%d%d", &n, &k);
vector<pair<pair<int, i... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
register int t = 0;
register char v = getchar();
while (v < '0') v = getchar();
while (v >= '0') t = (t << 3) + (t << 1) + v - 48, v = getchar();
return t;
}
int f[76][76], n, m, t, v[76][76], ans[76], cnt, pos;
struct node {
int x, y, id;
... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int inf = INT_MAX;
const long long inff = 1e18;
const long long mod = 1e9 + 7;
int dp[77][77];
int a[77], b[77];
int used[77];
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, k;
ci... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
vector<int> a(n);
vector<int> b(n);
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
if (n == k) {
vector<array<int, 2>> v(n);
... |
#include <bits/stdc++.h>
using namespace std;
int T, n, k;
struct card {
int a, b, id;
} A[105];
int f[105][105], fr[105][105];
int use[105], used[105], cnt, pos, num;
int cmp(card u, card v) { return u.b < v.b; }
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d %d", &n, &k);
for (int i = 1; i <= n; ... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 105;
long long n, k;
struct P {
long long x, y, id;
} a[N];
long long f[N][N], g[N][N];
bool maximize(long long &x, long long y) {
if (x < y) {
x = y;
return true;
}
return false;
}
void Main() {
cin >> n >> k;
for (long long i = 1, _... |
#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
long long gcd(long long a, long long b) { return b ... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1023456789;
struct minion {
int a, b, i;
};
void solve_case() {
int N, K;
cin >> N >> K;
vector<minion> minions(N);
for (int i = 0; i < N; ++i) {
cin >> minions[i].a >> minions[i].b;
minions[i].i = i;
}
sort(minions.begin(), minions.end... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 80;
const long long INF = 1e18 + 239;
long long dp[N][N];
long long wr[N][N];
void init() {
for (long long i = 0; i < N; i++) {
for (long long j = 0; j < N; j++) {
dp[i][j] = -INF;
wr[i][j] = -1;
}
}
dp[0][0] = 0;
}
void solve(l... |
#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const double E = 1e-8;
const double pi = acos(-1);
mt19937_64 rnd(time(0));
long long n, m, k, h, T;
long long dp[80][80... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
struct node {
long long id, add, val;
};
node p[100];
long long n, dp[100][100];
bool f[100];
bool cmp(node x, node y) { return x.add < y.add; }
deque<long long> ans;
void print(long long x, long long y) {
if (!y) return;
if (x && dp[x][y... |
#include <bits/stdc++.h>
using namespace std;
const long long buf_size = 1e5 + 5;
char buf[buf_size], *S, *T;
inline char read_char() {
if (S == T) T = (S = buf) + fread(buf, 1, buf_size, stdin);
return S != T ? *(S++) : EOF;
}
inline long long read_int() {
long long x = 0, f = 1;
char c = read_char();
while ... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
register int x = 0, f = 1;
register char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = 0;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + (ch ^ '0');
ch = getchar();
}
return f ? x : -x;
}
int n, k, f[80][80... |
#include <bits/stdc++.h>
using namespace std;
struct Edge {
long long to, dis, next, cost;
} edge[24050];
long long num = -1;
bool vis[10010];
long long mincost;
long long pre[10010], head[10010], cost[10010], last[10010], flow[10010], n, k,
a[110], b[110], s, t, maxflow;
long long to[110];
void add(long long f, ... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int N = 6000, M = 3e4;
struct edge {
int to, nxt;
int w, c;
} e[M];
int TT, n, m, x, y, k, a[80], b[80];
int ans, S, T, i, tot = 1, head[N], d[N], path[N];
queue<int> Q;
bool v[N];
void add(int x, int y, int w, int c) {
e[++tot] = {y, head[x... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
for (ll i = 0; i < v.size(); ++... |
#include <bits/stdc++.h>
using namespace std;
const int mxN = 80;
int N, K;
tuple<int, int, int> v[mxN];
int dp[mxN][mxN], pa[mxN][mxN];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
cin >> N >> K;
for (int i = (1); i <= (N); ++i) {
int A, B;
cin >> A... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
bool RELAXED = false;
template <int, typename T>
struct MINMAX {
T val;
MINMAX(T val) : val(val) {}
};
template <typename T>
MINMAX<1, T> MAX(T val) {
return MINMAX<1, T>(val);
};
template <typename T>
MINMAX<2, ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &n) {
n = 0;
T f = 1;
char c = getchar();
while (!isdigit(c) && c != '-') c = getchar();
if (c == '-') f = -1, c = getchar();
while (isdigit(c)) n = n * 10 + c - '0', c = getchar();
n *= f;
}
template <typename T>
void write(T... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T>
T poll(pqg<T> &x) {
T y = x.top();
x.pop();
return y;
}
template <int SZ>
struct mcmf {
struct Edge {
int to, rev;
long long flow, cap;
long long cost;
};
vec... |
#include <bits/stdc++.h>
using namespace std;
inline char gc() {
static char buf[1 << 16], *p1 = buf, *p2 = buf;
if (p1 == p2) {
p2 = (p1 = buf) + fread(buf, 1, 1 << 16, stdin);
if (p2 == p1) return EOF;
}
return *p1++;
}
template <class t>
inline t read(t &x) {
char c = gc();
bool f = 0;
x = 0;
... |
#include <bits/stdc++.h>
using namespace std;
int t, n, k;
long long dp[80][80];
vector<pair<pair<int, int>, int> > v;
long long solve(int i, int rem) {
if (i == n) {
if (rem) return -1e15;
return 0;
}
long long &ans = dp[i][rem];
if (ans != -1) return ans;
if (rem)
ans = solve(i + 1, rem - 1) + (... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
const long long INF = 1LL << 60;
const long long mod = 1e9 + 7;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
template <class T>
inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
templa... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Pii = pair<int, int>;
int uplg(int n) { return 32 - __builtin_clz(n); }
int uplg(ll n) { return 64 - __builtin_clzll(n); }
void run();
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(18... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
char buffer[2000020], *p1, *p2;
template <class T>
void read(T& x) {
char ch = ((p1 == p2 &&
(p2 = (p1 = buffer) + fread(buffer, 1, 2000020, stdin), p1 == p2))
? EOF
: *p1++);
x = 0;
bool f = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.