more cf
This commit is contained in:
parent
5fbc6203d0
commit
e9d0bc91a8
123 changed files with 3730 additions and 0 deletions
9
kattis/25-2-2025/.clang-format
Normal file
9
kattis/25-2-2025/.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
kattis/25-2-2025/.clangd
Normal file
8
kattis/25-2-2025/.clangd
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
CompileFlags:
|
||||
Add:
|
||||
- -Wall
|
||||
- -Wextra
|
||||
- -Wpedantic
|
||||
- -Wshadow
|
||||
- -DLOCAL
|
||||
- -Wno-unknown-pragmas
|
||||
95
kattis/25-2-2025/choosing-numbers.cc
Normal file
95
kattis/25-2-2025/choosing-numbers.cc
Normal 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 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;
|
||||
while (cin >> n) {
|
||||
vec<ll> a(n);
|
||||
for (auto& e : a) cin >> e;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
0
kattis/25-2-2025/choosing-numbers.in
Normal file
0
kattis/25-2-2025/choosing-numbers.in
Normal file
0
kattis/25-2-2025/choosing-numbers.out
Normal file
0
kattis/25-2-2025/choosing-numbers.out
Normal file
6
kattis/25-2-2025/compile_flags.txt
Normal file
6
kattis/25-2-2025/compile_flags.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
-DLOCAL
|
||||
-std=c++23
|
||||
88
kattis/25-2-2025/hitting-targets.cc
Normal file
88
kattis/25-2-2025/hitting-targets.cc
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
#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());
|
||||
}
|
||||
|
||||
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 m;
|
||||
cin >> m;
|
||||
string s;
|
||||
vec<vec<ld>> recs, circs;
|
||||
while (m--) {
|
||||
cin >> s;
|
||||
ld x1, y1, x2, y2, h, k, r;
|
||||
if (s[0] == 'r') {
|
||||
cin >> x1 >> y1 >> x2 >> y2;
|
||||
recs.pb({x1, y1, x2, y2});
|
||||
} else {
|
||||
cin >> h >> k >> r;
|
||||
circs.pb({h, k, r});
|
||||
}
|
||||
}
|
||||
int shots;
|
||||
cin >> shots;
|
||||
ld x, y;
|
||||
while (shots--) {
|
||||
cin >> x >> y;
|
||||
ll ans = 0;
|
||||
for (auto &r : recs) {
|
||||
if (y >= r[1] && y <= r[3] && x >= r[0] && x <= r[2])
|
||||
++ans;
|
||||
}
|
||||
for (auto &c : circs) {
|
||||
if (sqrtl(powl(x - c[0], 2) + powl(y - c[1], 2)) <= c[2]) {
|
||||
++ans;
|
||||
}
|
||||
}
|
||||
cout << ans << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
// cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
10
kattis/25-2-2025/hitting-targets.in
Normal file
10
kattis/25-2-2025/hitting-targets.in
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
3
|
||||
rectangle 1 1 10 5
|
||||
circle 5 0 8
|
||||
rectangle -5 3 5 8
|
||||
5
|
||||
1 1
|
||||
4 5
|
||||
10 10
|
||||
-10 -1
|
||||
4 -3
|
||||
8
kattis/25-2-2025/hitting-targets.out
Normal file
8
kattis/25-2-2025/hitting-targets.out
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
2
|
||||
3
|
||||
0
|
||||
0
|
||||
1
|
||||
|
||||
[code]: 0
|
||||
[time]: 12.0492 ms
|
||||
65
kattis/25-2-2025/quite-a-problem.cc
Normal file
65
kattis/25-2-2025/quite-a-problem.cc
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#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());
|
||||
}
|
||||
|
||||
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() {
|
||||
string s;
|
||||
string problem = "problem";
|
||||
while (getline(cin, s)) {
|
||||
transform(all(s), s.begin(), [](char c) {
|
||||
return std::tolower(c);
|
||||
});
|
||||
|
||||
cout << (s.find(problem) != string::npos ? "yes" : "no") << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
// cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
17
kattis/25-2-2025/quite-a-problem.in
Normal file
17
kattis/25-2-2025/quite-a-problem.in
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Problematic pair programming
|
||||
"There's a joke that pairs, like fish and house guests, go
|
||||
rotten after three days," said Zach Brock, an engineering
|
||||
manager. Working out problems with a pairing partner can be
|
||||
a lot like working out problems with a significant other.
|
||||
During one recent rough patch, Jamie Kite, a developer, sat
|
||||
her partner down for a talk. "Hey, it feels like we're
|
||||
driving in different directions," she recalls saying. "It's
|
||||
like any relationship," Ms. Kite said. "If you don't talk
|
||||
about the problems, it's not going to work." When those
|
||||
timeouts don't solve the problem, partners can turn to
|
||||
on-staff coaches who can help with counseling. "People who
|
||||
have been pairing a while, they'll start acting like old
|
||||
married couples," said Marc Phillips, one of the coaches.
|
||||
People can be as much of a challenge as writing software.
|
||||
(Excerpted from "Computer Programmers Learn Tough Lesson in
|
||||
Sharing"; Wall Street Journal, August 27, 2012)
|
||||
20
kattis/25-2-2025/quite-a-problem.out
Normal file
20
kattis/25-2-2025/quite-a-problem.out
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
yes
|
||||
no
|
||||
no
|
||||
yes
|
||||
yes
|
||||
no
|
||||
no
|
||||
no
|
||||
no
|
||||
yes
|
||||
yes
|
||||
no
|
||||
no
|
||||
no
|
||||
no
|
||||
no
|
||||
no
|
||||
|
||||
[code]: 0
|
||||
[time]: 11.6799 ms
|
||||
70
kattis/25-2-2025/ragged-right.cc
Normal file
70
kattis/25-2-2025/ragged-right.cc
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#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());
|
||||
}
|
||||
|
||||
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() {
|
||||
string line;
|
||||
vec<ll> lengths;
|
||||
while (getline(cin, line)) {
|
||||
lengths.eb(sz<ll>(line));
|
||||
}
|
||||
|
||||
ll ans = 0;
|
||||
ll large = *max_element(all(lengths));
|
||||
lengths.pop_back();
|
||||
for (auto l : lengths) {
|
||||
ans += (large - l) * (large - l);
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
// cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
5
kattis/25-2-2025/ragged-right.in
Normal file
5
kattis/25-2-2025/ragged-right.in
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
some blocks
|
||||
of text line up
|
||||
well on the right,
|
||||
but
|
||||
some don't.
|
||||
4
kattis/25-2-2025/ragged-right.out
Normal file
4
kattis/25-2-2025/ragged-right.out
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
283
|
||||
|
||||
[code]: 0
|
||||
[time]: 11.2939 ms
|
||||
135
kattis/25-2-2025/unicycle-counting.cc
Normal file
135
kattis/25-2-2025/unicycle-counting.cc
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
#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());
|
||||
}
|
||||
|
||||
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() {
|
||||
string line;
|
||||
|
||||
while (getline(cin, line)) {
|
||||
istringstream iss(line);
|
||||
ll m, n;
|
||||
iss >> m >> n;
|
||||
ll x;
|
||||
vector<ll> tires;
|
||||
vector<bool> has(m + 1, false);
|
||||
|
||||
while (n--) {
|
||||
iss >> x;
|
||||
tires.push_back(x);
|
||||
has[x] = true;
|
||||
}
|
||||
|
||||
ll ans = 0;
|
||||
ll i = 0;
|
||||
|
||||
while (i < tires.size()) {
|
||||
while (i < tires.size() && !has[tires[i]]) {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i >= tires.size()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == tires.size() - 1) {
|
||||
++ans;
|
||||
break;
|
||||
}
|
||||
|
||||
ll best_count = 0;
|
||||
ll best_delta = 0;
|
||||
|
||||
for (int advance = i + 1; advance < tires.size(); ++advance) {
|
||||
ll count = 0;
|
||||
ll delta = tires[advance] - tires[i];
|
||||
ll cur = tires[i];
|
||||
bool bad = false;
|
||||
|
||||
while (cur <= m - 1) {
|
||||
if (has[cur]) {
|
||||
++count;
|
||||
} else {
|
||||
bad = true;
|
||||
break;
|
||||
}
|
||||
cur += delta;
|
||||
}
|
||||
|
||||
if (bad) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count > best_count) {
|
||||
best_count = count;
|
||||
best_delta = delta;
|
||||
}
|
||||
}
|
||||
|
||||
if (best_delta == 0) {
|
||||
has[tires[i]] = false;
|
||||
++ans;
|
||||
continue;
|
||||
}
|
||||
|
||||
ll cur = tires[i];
|
||||
while (cur <= m - 1) {
|
||||
has[cur] = false;
|
||||
cur += best_delta;
|
||||
}
|
||||
|
||||
++ans;
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() { // {{{
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
// cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// }}}
|
||||
1
kattis/25-2-2025/unicycle-counting.in
Normal file
1
kattis/25-2-2025/unicycle-counting.in
Normal file
|
|
@ -0,0 +1 @@
|
|||
6 5 1 2 3 4 5
|
||||
5
kattis/25-2-2025/unicycle-counting.out
Normal file
5
kattis/25-2-2025/unicycle-counting.out
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
removing: 1 w/ delta 1
|
||||
1
|
||||
|
||||
[code]: 0
|
||||
[time]: 4.21095 ms
|
||||
Loading…
Add table
Add a link
Reference in a new issue