more cf
This commit is contained in:
parent
5fbc6203d0
commit
e9d0bc91a8
123 changed files with 3730 additions and 0 deletions
9
codeforces/1006/.clang-format
Normal file
9
codeforces/1006/.clang-format
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
BasedOnStyle: Google
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortCompoundRequirementOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: false
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLambdasOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
8
codeforces/1006/.clangd
Normal file
8
codeforces/1006/.clangd
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
CompileFlags:
|
||||
Add:
|
||||
- -Wall
|
||||
- -Wextra
|
||||
- -Wpedantic
|
||||
- -Wshadow
|
||||
- -DLOCAL
|
||||
- -Wno-unknown-pragmas
|
||||
101
codeforces/1006/a.cc
Normal file
101
codeforces/1006/a.cc
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
#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 T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto &&x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto &&x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt, Args &&...args) {
|
||||
std::print(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt) {
|
||||
std::print(fmt);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt, Args &&...args) {
|
||||
std::println(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt) {
|
||||
std::println(fmt);
|
||||
}
|
||||
|
||||
void prln() {
|
||||
std::println();
|
||||
}
|
||||
|
||||
void prln(auto const &t) {
|
||||
std::println("{}", t);
|
||||
}
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbgln(...) prln(...)
|
||||
#define dbg(...) pr(...)
|
||||
#endif
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
template <typename T, size_t N>
|
||||
using arr = std::array<T, N>;
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define pb push_back
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
int n, k, p;
|
||||
cin >> n >> k >> p;
|
||||
|
||||
k = abs(k);
|
||||
|
||||
int ans = k / p;
|
||||
k -= p * ans;
|
||||
if (k) {
|
||||
++ans;
|
||||
}
|
||||
|
||||
cout << (ans > n ? -1 : ans) << endl;
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
9
codeforces/1006/a.in
Normal file
9
codeforces/1006/a.in
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
8
|
||||
21 100 10
|
||||
9 -420 42
|
||||
5 -7 2
|
||||
13 37 7
|
||||
10 0 49
|
||||
1 10 9
|
||||
7 -7 7
|
||||
20 31 1
|
||||
11
codeforces/1006/a.out
Normal file
11
codeforces/1006/a.out
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
10
|
||||
-1
|
||||
4
|
||||
6
|
||||
0
|
||||
-1
|
||||
1
|
||||
-1
|
||||
|
||||
[code]: 0
|
||||
[time]: 11.3668 ms
|
||||
102
codeforces/1006/b.cc
Normal file
102
codeforces/1006/b.cc
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#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 T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto &&x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto &&x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt, Args &&...args) {
|
||||
std::print(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt) {
|
||||
std::print(fmt);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt, Args &&...args) {
|
||||
std::println(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt) {
|
||||
std::println(fmt);
|
||||
}
|
||||
|
||||
void prln() {
|
||||
std::println();
|
||||
}
|
||||
|
||||
void prln(auto const &t) {
|
||||
std::println("{}", t);
|
||||
}
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbgln(...) prln(...)
|
||||
#define dbg(...) pr(...)
|
||||
#endif
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
template <typename T, size_t N>
|
||||
using arr = std::array<T, N>;
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define pb push_back
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
int n;
|
||||
cin >> n;
|
||||
string s;
|
||||
cin >> s;
|
||||
ll hyphen = 0, underscore = 0;
|
||||
for (auto c : s) {
|
||||
hyphen += c == '-';
|
||||
underscore += c != '-';
|
||||
}
|
||||
|
||||
ll left = hyphen / 2, right = hyphen / 2 + (hyphen & 1);
|
||||
|
||||
cout << left * right * underscore << endl;
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
17
codeforces/1006/b.in
Normal file
17
codeforces/1006/b.in
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
8
|
||||
3
|
||||
--_
|
||||
5
|
||||
__-__
|
||||
9
|
||||
--__-_---
|
||||
4
|
||||
_--_
|
||||
10
|
||||
_-_-_-_-_-
|
||||
7
|
||||
_------
|
||||
1
|
||||
-
|
||||
2
|
||||
_-
|
||||
11
codeforces/1006/b.out
Normal file
11
codeforces/1006/b.out
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
1
|
||||
0
|
||||
27
|
||||
2
|
||||
30
|
||||
9
|
||||
0
|
||||
0
|
||||
|
||||
[code]: 0
|
||||
[time]: 12.301 ms
|
||||
130
codeforces/1006/c.cc
Normal file
130
codeforces/1006/c.cc
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
#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 T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt, Args&&... args) {
|
||||
std::print(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt) {
|
||||
std::print(fmt);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt, Args&&... args) {
|
||||
std::println(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt) {
|
||||
std::println(fmt);
|
||||
}
|
||||
|
||||
void prln() {
|
||||
std::println();
|
||||
}
|
||||
|
||||
void prln(auto const& t) {
|
||||
std::println("{}", t);
|
||||
}
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbgln(...) prln(...)
|
||||
#define dbg(...) pr(...)
|
||||
#endif
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
template <typename T, size_t N>
|
||||
using arr = std::array<T, N>;
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define pb push_back
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
ll n, x;
|
||||
cin >> n >> x;
|
||||
|
||||
ll cur = 0;
|
||||
|
||||
bool broken = false;
|
||||
if (n > 1) {
|
||||
cout << 0 << ' ';
|
||||
} else {
|
||||
cout << x << endl;
|
||||
return;
|
||||
}
|
||||
int a = 0;
|
||||
for (int i = 0; i < n - 2; ++i) {
|
||||
++cur;
|
||||
|
||||
if (broken || (cur | x) > x) {
|
||||
broken = true;
|
||||
}
|
||||
|
||||
if (broken) {
|
||||
cout << x;
|
||||
a |= x;
|
||||
} else {
|
||||
cout << cur;
|
||||
a |= cur;
|
||||
}
|
||||
cout << ' ';
|
||||
}
|
||||
|
||||
++cur;
|
||||
|
||||
if (broken) {
|
||||
cout << x;
|
||||
} else {
|
||||
if ((cur | x) <= x && (a | cur) == x) {
|
||||
cout << cur;
|
||||
} else
|
||||
cout << x;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
10
codeforces/1006/c.in
Normal file
10
codeforces/1006/c.in
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
9
|
||||
1 69
|
||||
7 7
|
||||
5 7
|
||||
7 3
|
||||
8 7
|
||||
3 52
|
||||
9 11
|
||||
6 15
|
||||
2 3
|
||||
12
codeforces/1006/c.out
Normal file
12
codeforces/1006/c.out
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
69
|
||||
0 1 2 3 4 5 6
|
||||
0 1 2 3 4
|
||||
0 1 2 3 3 3 3
|
||||
0 1 2 3 4 5 6 7
|
||||
0 52 52
|
||||
0 1 2 3 11 11 11 11 11
|
||||
0 1 2 3 4 15
|
||||
0 3
|
||||
|
||||
[code]: 0
|
||||
[time]: 11.3029 ms
|
||||
6
codeforces/1006/compile_flags.txt
Normal file
6
codeforces/1006/compile_flags.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
-DLOCAL
|
||||
-std=c++23
|
||||
108
codeforces/1006/d.cc
Normal file
108
codeforces/1006/d.cc
Normal 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 T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto &&x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto &&x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt, Args &&...args) {
|
||||
std::print(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt) {
|
||||
std::print(fmt);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt, Args &&...args) {
|
||||
std::println(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt) {
|
||||
std::println(fmt);
|
||||
}
|
||||
|
||||
void prln() {
|
||||
std::println();
|
||||
}
|
||||
|
||||
void prln(auto const &t) {
|
||||
std::println("{}", t);
|
||||
}
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbgln(...) prln(...)
|
||||
#define dbg(...) pr(...)
|
||||
#endif
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
template <typename T, size_t N>
|
||||
using arr = std::array<T, N>;
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define pb push_back
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
int n;
|
||||
cin >> n;
|
||||
vec<ll> a(n);
|
||||
for (auto &e : a) {
|
||||
cin >> e;
|
||||
}
|
||||
|
||||
arr<int, 3> ans{0, 0, 0};
|
||||
|
||||
for (int l = 0; l < sz<int>(a); ++l) {
|
||||
ll delta = 0;
|
||||
for (int r = l + 1; r < sz<int>(a); ++r) {
|
||||
delta += a[l] < a[r];
|
||||
delta -= a[l] > a[r];
|
||||
ans = min(ans, {delta, l, r});
|
||||
}
|
||||
}
|
||||
|
||||
prln("{} {}", ans[1] + 1, ans[2] + 1);
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
19
codeforces/1006/d.in
Normal file
19
codeforces/1006/d.in
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
9
|
||||
7
|
||||
1 4 3 2 5 3 3
|
||||
6
|
||||
1 4 3 2 5 3
|
||||
8
|
||||
7 6 5 8 4 3 2 1
|
||||
10
|
||||
1 1 1 5 1 1 5 6 7 8
|
||||
2
|
||||
1337 69
|
||||
4
|
||||
2 1 2 1
|
||||
3
|
||||
998 244 353
|
||||
3
|
||||
1 2 1
|
||||
9
|
||||
1 1 2 3 5 8 13 21 34
|
||||
12
codeforces/1006/d.out
Normal file
12
codeforces/1006/d.out
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
2 7
|
||||
2 6
|
||||
1 8
|
||||
4 7
|
||||
1 2
|
||||
1 4
|
||||
1 3
|
||||
2 3
|
||||
1 2
|
||||
|
||||
[code]: 0
|
||||
[time]: 3.81064 ms
|
||||
115
codeforces/1006/e.cc
Normal file
115
codeforces/1006/e.cc
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
#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 T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::max();
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sc(auto&& x) {
|
||||
return static_cast<T>(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] static T sz(auto&& x) {
|
||||
return static_cast<T>(x.size());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt, Args&&... args) {
|
||||
std::print(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void pr(std::format_string<Args...> fmt) {
|
||||
std::print(fmt);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt, Args&&... args) {
|
||||
std::println(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void prln(std::format_string<Args...> fmt) {
|
||||
std::println(fmt);
|
||||
}
|
||||
|
||||
void prln() {
|
||||
std::println();
|
||||
}
|
||||
|
||||
void prln(auto const& t) {
|
||||
std::println("{}", t);
|
||||
}
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbgln(...) prln(...)
|
||||
#define dbg(...) pr(...)
|
||||
#endif
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
template <typename T, size_t N>
|
||||
using arr = std::array<T, N>;
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define pb push_back
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (x).rbegin(), (x).rend()
|
||||
// }}}
|
||||
|
||||
void solve() {
|
||||
ll k;
|
||||
cin >> k;
|
||||
ll y = 0, x = 0;
|
||||
vec<pair<ll, ll>> ans;
|
||||
|
||||
while (k) {
|
||||
ll count = 0;
|
||||
|
||||
while (count * (count - 1) / 2 <= k) {
|
||||
++count;
|
||||
}
|
||||
|
||||
--count;
|
||||
|
||||
k -= count * (count - 1) / 2;
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
ans.eb(x, y++);
|
||||
}
|
||||
++x;
|
||||
}
|
||||
|
||||
cout << ans.size() << endl;
|
||||
for (auto [a, b] : ans) {
|
||||
cout << a << ' ' << b << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
4
codeforces/1006/e.in
Normal file
4
codeforces/1006/e.in
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
15
codeforces/1006/e.out
Normal file
15
codeforces/1006/e.out
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
2
|
||||
0 0
|
||||
0 1
|
||||
4
|
||||
0 0
|
||||
0 1
|
||||
1 2
|
||||
1 3
|
||||
3
|
||||
0 0
|
||||
0 1
|
||||
0 2
|
||||
|
||||
[code]: 0
|
||||
[time]: 11.3349 ms
|
||||
Loading…
Add table
Add a link
Reference in a new issue