feat(cf): update ignore

This commit is contained in:
Barrett Ruth 2025-02-03 10:41:37 -05:00
parent 742bf851a9
commit 490d4aa62f
25 changed files with 739 additions and 217 deletions

View file

@ -0,0 +1,9 @@
BasedOnStyle: Google
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: false
AllowShortLoopsOnASingleLine: false

95
codeforces/971/a.cc Normal file
View file

@ -0,0 +1,95 @@
#include <bits/stdc++.h>
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
template <typename... Args>
void dbg(std::string const &str, Args &&...args) {
std::cout << std::vformat(str, std::make_format_args(args...));
}
template <typename T>
void dbg(T const &t) {
std::cout << t;
}
template <std::ranges::range T>
void dbgln(T const &t) {
if constexpr (std::is_convertible_v<T, char const *>) {
std::cout << t << '\n';
} else {
for (auto const &e : t) {
std::cout << e << ' ';
}
std::cout << '\n';
}
}
template <typename... Args>
void dbgln(std::string const &str, Args &&...args) {
dbg(str, std::forward<Args>(args)...);
cout << '\n';
}
template <typename T>
void dbgln(T const &t) {
dbg("{}\n", t);
}
void println() {
std::cout << '\n';
}
template <typename T>
constexpr T MIN = std::numeric_limits<T>::min();
template <typename T>
constexpr T MAX = std::numeric_limits<T>::min();
#define ff first
#define ss second
#define eb emplace_back
#define ll long long
#define ld long double
#define vec vector
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (r).rbegin(), (x).rend()
#define sz(x) static_cast<int>((x).size())
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (int(a) = (b); (a) > (c); --(a))
std::random_device rd;
std::mt19937 gen(rd());
void YES() {
cout << "YES\n";
}
void NO() {
cout << "NO\n";
}
void solve() {
int a, b;
cin >> a >> b;
dbgln(b - a);
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}

4
codeforces/971/a.in Normal file
View file

@ -0,0 +1,4 @@
3
1 2
3 10
5 5

108
codeforces/971/b.cc Normal file
View file

@ -0,0 +1,108 @@
#include <bits/stdc++.h>
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
template <typename... Args>
void dbg(std::string const &str, Args &&...args) {
std::cout << std::vformat(str, std::make_format_args(args...));
}
template <typename T>
void dbg(T const &t) {
std::cout << t;
}
template <std::ranges::range T>
void dbgln(T const &t) {
if constexpr (std::is_convertible_v<T, char const *>) {
std::cout << t << '\n';
} else {
for (auto const &e : t) {
std::cout << e << ' ';
}
std::cout << '\n';
}
}
template <typename... Args>
void dbgln(std::string const &str, Args &&...args) {
dbg(str, std::forward<Args>(args)...);
cout << '\n';
}
template <typename T>
void dbgln(T const &t) {
dbg("{}\n", t);
}
void dbgln() {
std::cout << '\n';
}
template <typename T>
constexpr T MIN = std::numeric_limits<T>::min();
template <typename T>
constexpr T MAX = std::numeric_limits<T>::min();
#define ff first
#define ss second
#define eb emplace_back
#define ll long long
#define ld long double
#define vec vector
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (r).rbegin(), (x).rend()
#define sz(x) static_cast<int>((x).size())
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (int(a) = (b); (a) > (c); --(a))
std::random_device rd;
std::mt19937 gen(rd());
void YES() {
cout << "YES\n";
}
void NO() {
cout << "NO\n";
}
void solve() {
int n;
cin >> n;
vec<int> ans;
while (n--) {
string s;
cin >> s;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == '#')
ans.push_back(i + 1);
}
}
while (!ans.empty()) {
dbg("{} ", ans.back());
ans.pop_back();
}
dbgln();
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}

11
codeforces/971/b.in Normal file
View file

@ -0,0 +1,11 @@
3
4
#...
.#..
..#.
...#
2
.#..
.#..
1
...#

3
codeforces/971/b.out Normal file
View file

@ -0,0 +1,3 @@
4 3 2 1
2 2
4

99
codeforces/971/c.cc Normal file
View file

@ -0,0 +1,99 @@
#include <bits/stdc++.h>
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
template <typename... Args>
void dbg(std::string const &str, Args &&...args) {
std::cout << std::vformat(str, std::make_format_args(args...));
}
template <typename T>
void dbg(T const &t) {
std::cout << t;
}
template <std::ranges::range T>
void dbgln(T const &t) {
if constexpr (std::is_convertible_v<T, char const *>) {
std::cout << t << '\n';
} else {
for (auto const &e : t) {
std::cout << e << ' ';
}
std::cout << '\n';
}
}
template <typename... Args>
void dbgln(std::string const &str, Args &&...args) {
dbg(str, std::forward<Args>(args)...);
cout << '\n';
}
template <typename T>
void dbgln(T const &t) {
dbg("{}\n", t);
}
void println() {
std::cout << '\n';
}
template <typename T>
constexpr T MIN = std::numeric_limits<T>::min();
template <typename T>
constexpr T MAX = std::numeric_limits<T>::min();
#define ff first
#define ss second
#define eb emplace_back
#define ll long long
#define ld long double
#define vec vector
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (r).rbegin(), (x).rend()
#define sz(x) static_cast<int>((x).size())
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (int(a) = (b); (a) > (c); --(a))
std::random_device rd;
std::mt19937 gen(rd());
void YES() {
cout << "YES\n";
}
void NO() {
cout << "NO\n";
}
void solve() {
int x, y, k;
cin >> x >> y >> k;
int xleft = 2 * ((x + k - 1) / k) - 1;
int yleft = 2 * ((y + k - 1) / k);
dbgln(max(xleft, yleft));
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}

4
codeforces/971/c.in Normal file
View file

@ -0,0 +1,4 @@
3
9 11 3
0 10 8
1000000 100000 10

3
codeforces/971/c.out Normal file
View file

@ -0,0 +1,3 @@
8
4
199999

View file

@ -0,0 +1,5 @@
-std=c++20
-Wall
-Wextra
-Wpedantic
-Wshadow

117
codeforces/971/d.cc Normal file
View file

@ -0,0 +1,117 @@
#include <bits/stdc++.h>
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
template <typename... Args>
void dbg(std::string const &str, Args &&...args) {
std::cout << std::vformat(str, std::make_format_args(args...));
}
template <typename T>
void dbg(T const &t) {
std::cout << t;
}
template <std::ranges::range T>
void dbgln(T const &t) {
if constexpr (std::is_convertible_v<T, char const *>) {
std::cout << t << '\n';
} else {
for (auto const &e : t) {
std::cout << e << ' ';
}
std::cout << '\n';
}
}
template <typename... Args>
void dbgln(std::string const &str, Args &&...args) {
dbg(str, std::forward<Args>(args)...);
cout << '\n';
}
template <typename T>
void dbgln(T const &t) {
dbg("{}\n", t);
}
void prllln() {
std::cout << '\n';
}
template <typename T>
constexpr T MIN = std::numeric_limits<T>::min();
template <typename T>
constexpr T MAX = std::numeric_limits<T>::min();
#define ff first
#define ss second
#define eb emplace_back
#define ll long long
#define ld long double
#define vec vector
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (r).rbegin(), (x).rend()
#define sz(x) static_cast<ll>((x).size())
#define FOR(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (ll(a) = (b); (a) > (c); --(a))
std::random_device rd;
std::mt19937 gen(rd());
void YES() {
cout << "YES\n";
}
void NO() {
cout << "NO\n";
}
constexpr auto N_MAX = (2 * 100000) + 1;
bitset<N_MAX> y_one, y_zero;
void solve() {
ll n;
cin >> n;
y_one.reset();
y_zero.reset();
FOR(i, 0, n) {
ll x, y;
cin >> x >> y;
y_one[x] = y_one[x] | (y == 1);
y_zero[x] = y_zero[x] | (y == 0);
}
ll ans = 0;
FOR(x, 0, n + 1) {
if (y_one[x] && y_zero[x])
ans += n - 2;
if (x >= 1 && x < n && y_one[x] && y_zero[x - 1] && y_zero[x + 1])
++ans;
if (x >= 1 && x < n && y_zero[x] && y_one[x - 1] && y_one[x + 1])
++ans;
}
dbgln(ans);
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
ll t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}

21
codeforces/971/d.in Normal file
View file

@ -0,0 +1,21 @@
3
5
1 0
1 1
3 0
5 0
2 1
3
0 0
1 0
3 0
9
1 0
2 0
3 0
4 0
5 0
2 1
7 1
8 1
9 1

3
codeforces/971/d.out Normal file
View file

@ -0,0 +1,3 @@
4
0
8

53
codeforces/971/e.cc Normal file
View file

@ -0,0 +1,53 @@
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
#define ll long long
using ld = long double;
auto inclusive_sum = [](unsigned ll l, unsigned ll r) {
unsigned ll sum_r = r / 2 * (r + 1);
if (r % 2)
sum_r += (r + 1) / 2;
l--;
unsigned ll sum_l = l / 2 * (l + 1);
if (l % 2)
sum_l += (l + 1) / 2;
return sum_r - sum_l;
};
auto quad = [](ld a, ld b, ld c) {
return (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
};
void solve() {
unsigned ll n, k;
cin >> n >> k;
ll half = inclusive_sum(k, k + n - 1) / 2;
ld i = quad(0.5, k + 0.5, -half);
unsigned ll a = max(1LL, static_cast<ll>(ceil(i)));
unsigned ll b = min(n, a + 1);
unsigned ll x = inclusive_sum(k, k + a - 1);
unsigned ll y = inclusive_sum(k + a, k + n - 1);
unsigned ll diff1 = x < y ? y - x : x - y;
x = inclusive_sum(k, k + b - 1);
y = inclusive_sum(k + b, k + n - 1);
unsigned ll diff2 = x < y ? y - x : x - y;
cout << min(diff1, diff2) << endl;
}
int main() {
int t;
cin >> t;
while (t--)
solve();
return 0;
}

5
codeforces/971/e.in Normal file
View file

@ -0,0 +1,5 @@
4
2 2
7 2
5 3
999999999 999999999

4
codeforces/971/e.out Normal file
View file

@ -0,0 +1,4 @@
1
5
1
1490352408

BIN
codeforces/971/exe Executable file

Binary file not shown.

143
codeforces/971/f.cc Normal file
View file

@ -0,0 +1,143 @@
#include <bits/stdc++.h>
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
template <typename... Args>
void dbg(std::string const &str, Args &&...args) {
std::cout << std::vformat(str, std::make_format_args(args...));
}
template <typename T>
void dbg(T const &t) {
std::cout << t;
}
template <std::ranges::range T>
void dbgln(T const &t) {
if constexpr (std::is_convertible_v<T, char const *>) {
std::cout << t << '\n';
} else {
for (auto const &e : t) {
std::cout << e << ' ';
}
std::cout << '\n';
}
}
void dbgln() {
std::cout << '\n';
}
template <typename... Args>
void dbgln(std::string const &str, Args &&...args) {
dbg(str, std::forward<Args>(args)...);
cout << '\n';
}
template <typename T>
void dbgln(T const &t) {
dbg(t);
cout << '\n';
}
template <typename T>
constexpr T MIN = std::numeric_limits<T>::min();
template <typename T>
constexpr T MAX = std::numeric_limits<T>::min();
template <typename T>
static T sc(auto &&x) {
return static_cast<T>(x);
}
#define ff first
#define ss second
#define eb emplace_back
#define ll long long
#define ld long double
#define vec vector
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (r).rbegin(), (x).rend()
#define sz(x) static_cast<int>((x).size())
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (int(a) = (b); (a) > (c); --(a))
std::random_device rd;
std::mt19937 gen(rd());
void solve() {
int n, q;
cin >> n >> q;
ll A = 0;
vec<ll> prefix;
prefix.push_back(0);
FOR(i, 0, n) {
ll x;
cin >> x;
A += x;
prefix.push_back(A);
}
// TODO: WRITE A BETTER MIN
// c_k = [a_k, a_k+1, ..., a_n ,a_1, ..., ak-1]
// [a_2, a_0, a_1]
// i = 2
auto shift_sum = [&](int k, int i) -> ll {
if (i == -1)
return 0;
int shifted_i = (i + k) % n;
if (shifted_i < k) {
return prefix[n] - prefix[k] + prefix[shifted_i + 1];
}
return prefix[shifted_i + 1] - prefix[k];
};
FOR(i, 0, q) {
ll l, r;
cin >> l >> r;
--l;
--r;
int I = l / n, J = r / n;
l = l % n, r = r % n;
ll ans;
if (I != J)
ans =
max(0LL, (J - I - 1) * A) + A - shift_sum(I, l - 1) + shift_sum(J, r);
else {
int shifted_l = (l + I) % n;
int shifted_r = (r + I) % n;
if (shifted_l <= shifted_r)
ans = prefix[shifted_r + 1] - prefix[shifted_l];
else
ans = prefix[n] - prefix[shifted_l] + prefix[shifted_r + 1];
}
dbgln(ans);
}
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}

30
codeforces/971/f.in Normal file
View file

@ -0,0 +1,30 @@
5
3 3
1 2 3
1 9
3 5
8 8
5 5
4 8 3 2 4
1 14
3 7
7 10
2 11
1 25
1 1
6
1 1
5 7
3 1 6 10 4
3 21
6 17
2 2
1 5
1 14
9 15
12 13
5 3
4 9 10 10 1
20 25
3 11
20 22

19
codeforces/971/f.out Normal file
View file

@ -0,0 +1,19 @@
18
8
1
55
20
13
41
105
6
96
62
1
24
71
31
14
44
65
15