codeforces: 1003
This commit is contained in:
parent
7440bc2937
commit
d1b961e1c4
60 changed files with 2235 additions and 0 deletions
9
codeforces/957/.clang-format
Normal file
9
codeforces/957/.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/957/.clangd
Normal file
8
codeforces/957/.clangd
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
CompileFlags:
|
||||
Add:
|
||||
- -std=c++23
|
||||
- -Wall
|
||||
- -Wextra
|
||||
- -Wpedantic
|
||||
- -Wshadow
|
||||
- -Wno-unknown-pragmas
|
||||
87
codeforces/957/a.cc
Normal file
87
codeforces/957/a.cc
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
#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);
|
||||
}
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#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()
|
||||
|
||||
#define FORI(a, b, c) for (int a = (b); a < (c); ++a)
|
||||
#define ROFI(a, b, c) for (int a = (b); a > (c); --a)
|
||||
#define FORLL(a, b, c) for (ll a = (b); a < (c); ++a)
|
||||
#define ROFLL(a, b, c) for (ll a = (b); a > (c); --a) // }}}
|
||||
|
||||
void solve() {
|
||||
ll a, b, c;
|
||||
cin >> a >> b >> c;
|
||||
|
||||
ll ans = 0;
|
||||
FORI(i, 0, 5 + 1) {
|
||||
FORI(j, 0, 5 - i + 1) {
|
||||
ans = max(ans, (a + i) * (b + j) * (c + (5 - i - j)));
|
||||
}
|
||||
}
|
||||
prln("{}", ans);
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
} //}}}
|
||||
3
codeforces/957/a.in
Normal file
3
codeforces/957/a.in
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
2
|
||||
2 3 4
|
||||
10 1 10
|
||||
5
codeforces/957/a.out
Normal file
5
codeforces/957/a.out
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
100
|
||||
600
|
||||
|
||||
[code]: 0
|
||||
[time]: 10.5841 ms
|
||||
93
codeforces/957/b.cc
Normal file
93
codeforces/957/b.cc
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#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);
|
||||
}
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#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()
|
||||
|
||||
#define FORI(a, b, c) for (int a = (b); a < (c); ++a)
|
||||
#define ROFI(a, b, c) for (int a = (b); a > (c); --a)
|
||||
#define FORLL(a, b, c) for (ll a = (b); a < (c); ++a)
|
||||
#define ROFLL(a, b, c) for (ll a = (b); a > (c); --a) // }}}
|
||||
|
||||
void solve() {
|
||||
int n, k;
|
||||
cin >> n >> k;
|
||||
vec<int> a(k);
|
||||
for (auto& e : a)
|
||||
cin >> e;
|
||||
|
||||
sort(all(a));
|
||||
|
||||
ll ans = 0;
|
||||
FORI(i, 0, sz<int>(a) - 1) {
|
||||
if (a[i] > 1) {
|
||||
ans += (a[i] << 1) - 1;
|
||||
} else
|
||||
++ans;
|
||||
}
|
||||
prln("{}", ans);
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
} //}}}
|
||||
9
codeforces/957/b.in
Normal file
9
codeforces/957/b.in
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
4
|
||||
5 3
|
||||
3 1 1
|
||||
5 2
|
||||
3 2
|
||||
11 4
|
||||
2 3 1 5
|
||||
16 6
|
||||
1 6 1 1 1 6
|
||||
7
codeforces/957/b.out
Normal file
7
codeforces/957/b.out
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
2
|
||||
3
|
||||
9
|
||||
15
|
||||
|
||||
[code]: 0
|
||||
[time]: 12.924 ms
|
||||
87
codeforces/957/c.cc
Normal file
87
codeforces/957/c.cc
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
#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);
|
||||
}
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#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()
|
||||
|
||||
#define FORI(a, b, c) for (int a = (b); a < (c); ++a)
|
||||
#define ROFI(a, b, c) for (int a = (b); a > (c); --a)
|
||||
#define FORLL(a, b, c) for (ll a = (b); a < (c); ++a)
|
||||
#define ROFLL(a, b, c) for (ll a = (b); a > (c); --a) // }}}
|
||||
|
||||
void solve() {
|
||||
int n, m, k;
|
||||
cin >> n >> m >> k;
|
||||
|
||||
ROFI(x, n, m) {
|
||||
pr("{} ", x);
|
||||
}
|
||||
FORI(x, 1, m + 1) {
|
||||
pr("{} ", x);
|
||||
}
|
||||
println();
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
} //}}}
|
||||
4
codeforces/957/c.in
Normal file
4
codeforces/957/c.in
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
3
|
||||
5 2 5
|
||||
3 1 3
|
||||
10 3 8
|
||||
6
codeforces/957/c.out
Normal file
6
codeforces/957/c.out
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
5 4 3 1 2
|
||||
3 2 1
|
||||
10 9 8 7 6 5 4 1 2 3
|
||||
|
||||
[code]: 0
|
||||
[time]: 4.05407 ms
|
||||
5
codeforces/957/compile_flags.txt
Normal file
5
codeforces/957/compile_flags.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-std=c++23
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
119
codeforces/957/d.cc
Normal file
119
codeforces/957/d.cc
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
#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);
|
||||
}
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#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()
|
||||
|
||||
#define FORI(a, b, c) for (int a = (b); a < (c); ++a)
|
||||
#define ROFI(a, b, c) for (int a = (b); a > (c); --a)
|
||||
#define FORLL(a, b, c) for (ll a = (b); a < (c); ++a)
|
||||
#define ROFLL(a, b, c) for (ll a = (b); a > (c); --a) // }}}
|
||||
|
||||
void solve() {
|
||||
int _, jump, swim;
|
||||
cin >> _ >> jump >> swim;
|
||||
string s;
|
||||
cin >> s;
|
||||
|
||||
int get_to = 0;
|
||||
vec<int> logs;
|
||||
FORI(i, 0, sz<int>(s)) {
|
||||
if (s[i] == 'L')
|
||||
logs.pb(i);
|
||||
}
|
||||
|
||||
logs.pb(sz<int>(s) + 1);
|
||||
|
||||
int pos = -1;
|
||||
bool done = true;
|
||||
while (pos < sz<int>(s)) {
|
||||
auto diff = logs[get_to] - pos;
|
||||
if (jump < diff) {
|
||||
if ((pos += jump) < sz<int>(s)) {
|
||||
while (pos < sz<int>(s) && pos < logs[get_to]) {
|
||||
if (s[pos] == 'C' || swim == 0) {
|
||||
done = false;
|
||||
break;
|
||||
}
|
||||
++pos;
|
||||
--swim;
|
||||
}
|
||||
if (!done)
|
||||
break;
|
||||
} else
|
||||
break;
|
||||
} else {
|
||||
pos = logs[get_to];
|
||||
}
|
||||
++get_to;
|
||||
}
|
||||
|
||||
if (done)
|
||||
prln("YES");
|
||||
else
|
||||
prln("NO");
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
} //}}}
|
||||
13
codeforces/957/d.in
Normal file
13
codeforces/957/d.in
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
6
|
||||
6 2 0
|
||||
LWLLLW
|
||||
6 1 1
|
||||
LWLLLL
|
||||
6 1 1
|
||||
LWLLWL
|
||||
6 2 15
|
||||
LWLLCC
|
||||
6 10 0
|
||||
CCCCCC
|
||||
6 6 1
|
||||
WCCCCW
|
||||
9
codeforces/957/d.out
Normal file
9
codeforces/957/d.out
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
YES
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
YES
|
||||
|
||||
[code]: 0
|
||||
[time]: 18.3692 ms
|
||||
81
codeforces/957/f.cc
Normal file
81
codeforces/957/f.cc
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#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);
|
||||
}
|
||||
|
||||
using ll = long long;
|
||||
using ld = long double;
|
||||
template <typename T>
|
||||
using vec = std::vector<T>;
|
||||
|
||||
#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() {
|
||||
prln(5);
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
} //}}}
|
||||
17
codeforces/957/f.in
Normal file
17
codeforces/957/f.in
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
8
|
||||
6 4
|
||||
2 3 6 2 1 2
|
||||
9 100000
|
||||
50000 25000 12500 6250 3125 2 4 8 16
|
||||
5 2
|
||||
1 1 1 1 1
|
||||
8 6
|
||||
4 3 4 3 4 3 4 3
|
||||
7 12
|
||||
6 11 1 3 11 10 2
|
||||
10 5
|
||||
2 4 4 2 4 4 4 3 1 1
|
||||
7 8
|
||||
4 6 5 1 2 4 1
|
||||
8 27
|
||||
3 9 17 26 2 20 9 3
|
||||
11
codeforces/957/f.out
Normal file
11
codeforces/957/f.out
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
5
|
||||
|
||||
[code]: 0
|
||||
[time]: 12.038 ms
|
||||
Loading…
Add table
Add a link
Reference in a new issue