feat(codeforces/937): a-f
This commit is contained in:
parent
a95b53b397
commit
446ad865d0
26 changed files with 815 additions and 0 deletions
9
codeforces/937/.clang-format
Normal file
9
codeforces/937/.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
|
||||||
34
codeforces/937/.clangd
Normal file
34
codeforces/937/.clangd
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
CompileFlags:
|
||||||
|
Add:
|
||||||
|
-O2
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Wpedantic
|
||||||
|
-Wshadow
|
||||||
|
-Wformat=2
|
||||||
|
-Wfloat-equal
|
||||||
|
-Wlogical-op
|
||||||
|
-Wshift-overflow=2
|
||||||
|
-Wnon-virtual-dtor
|
||||||
|
-Wold-style-cast
|
||||||
|
-Wcast-qual
|
||||||
|
-Wuseless-cast
|
||||||
|
-Wno-sign-promotion
|
||||||
|
-Wcast-align
|
||||||
|
-Wunused
|
||||||
|
-Woverloaded-virtual
|
||||||
|
-Wconversion
|
||||||
|
-Wsign-conversion
|
||||||
|
-Wmisleading-indentation
|
||||||
|
-Wduplicated-cond
|
||||||
|
-Wduplicated-branches
|
||||||
|
-Wlogical-op
|
||||||
|
-Wnull-dereference
|
||||||
|
-Wformat=2
|
||||||
|
-Wformat-overflow
|
||||||
|
-Wformat-truncation
|
||||||
|
-Wdouble-promotion
|
||||||
|
-Wundef
|
||||||
|
-DLOCAL
|
||||||
|
-std=c++20
|
||||||
|
-Wno-unknown-pragmas
|
||||||
44
codeforces/937/a.cc
Normal file
44
codeforces/937/a.cc
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
#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;
|
||||||
|
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 a, b, c;
|
||||||
|
cin >> a >> b >> c;
|
||||||
|
if (a < b && b < c) {
|
||||||
|
cout << "STAIR";
|
||||||
|
} else if (a < b && b > c) {
|
||||||
|
cout << "PEAK";
|
||||||
|
} else {
|
||||||
|
cout << "NONE";
|
||||||
|
}
|
||||||
|
cout << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
cin.exceptions(cin.failbit);
|
||||||
|
|
||||||
|
int tc = 1;
|
||||||
|
cin >> tc;
|
||||||
|
|
||||||
|
for (int t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
54
codeforces/937/b.cc
Normal file
54
codeforces/937/b.cc
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#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;
|
||||||
|
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 n;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
vector<vector<char>> board(2 * n, vector<char>(2 * n, '.'));
|
||||||
|
for (u32 i = 0; i < n; ++i) {
|
||||||
|
for (u32 j = 0; j < n; ++j) {
|
||||||
|
if ((i & 1) == (j & 1)) {
|
||||||
|
board[2 * i][2 * j] = '#';
|
||||||
|
board[2 * i + 1][2 * j] = '#';
|
||||||
|
board[2 * i + 1][2 * j + 1] = '#';
|
||||||
|
board[2 * i][2 * j + 1] = '#';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& r : board) {
|
||||||
|
for (auto& c : r) {
|
||||||
|
cout << c;
|
||||||
|
}
|
||||||
|
cout << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
cin.exceptions(cin.failbit);
|
||||||
|
|
||||||
|
int tc = 1;
|
||||||
|
cin >> tc;
|
||||||
|
|
||||||
|
for (int t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
55
codeforces/937/c.cc
Normal file
55
codeforces/937/c.cc
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
#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;
|
||||||
|
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
string time;
|
||||||
|
cin >> time;
|
||||||
|
u32 hour = stoi(time.substr(0, 2));
|
||||||
|
u32 minute = stoi(time.substr(3, 2));
|
||||||
|
|
||||||
|
bool pm = hour >= 12;
|
||||||
|
if (hour > 12) {
|
||||||
|
hour %= 12;
|
||||||
|
}
|
||||||
|
if (hour == 0) {
|
||||||
|
hour = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hour < 10) {
|
||||||
|
cout << '0';
|
||||||
|
}
|
||||||
|
cout << hour << ':';
|
||||||
|
if (minute < 10) {
|
||||||
|
cout << '0';
|
||||||
|
}
|
||||||
|
cout << minute << ' ' << (pm ? "PM" : "AM") << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
cin.exceptions(cin.failbit);
|
||||||
|
|
||||||
|
int tc = 1;
|
||||||
|
cin >> tc;
|
||||||
|
|
||||||
|
for (int t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
31
codeforces/937/compile_flags.txt
Normal file
31
codeforces/937/compile_flags.txt
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
-O2
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Wpedantic
|
||||||
|
-Wshadow
|
||||||
|
-Wformat=2
|
||||||
|
-Wfloat-equal
|
||||||
|
-Wlogical-op
|
||||||
|
-Wshift-overflow=2
|
||||||
|
-Wnon-virtual-dtor
|
||||||
|
-Wold-style-cast
|
||||||
|
-Wcast-qual
|
||||||
|
-Wuseless-cast
|
||||||
|
-Wno-sign-promotion
|
||||||
|
-Wcast-align
|
||||||
|
-Wunused
|
||||||
|
-Woverloaded-virtual
|
||||||
|
-Wconversion
|
||||||
|
-Wsign-conversion
|
||||||
|
-Wmisleading-indentation
|
||||||
|
-Wduplicated-cond
|
||||||
|
-Wduplicated-branches
|
||||||
|
-Wlogical-op
|
||||||
|
-Wnull-dereference
|
||||||
|
-Wformat=2
|
||||||
|
-Wformat-overflow
|
||||||
|
-Wformat-truncation
|
||||||
|
-Wdouble-promotion
|
||||||
|
-Wundef
|
||||||
|
-DLOCAL
|
||||||
|
-std=c++20
|
||||||
171
codeforces/937/d.cc
Normal file
171
codeforces/937/d.cc
Normal file
|
|
@ -0,0 +1,171 @@
|
||||||
|
#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;
|
||||||
|
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
#include <ext/pb_ds/assoc_container.hpp>
|
||||||
|
#include <ext/pb_ds/tree_policy.hpp>
|
||||||
|
|
||||||
|
using namespace __gnu_pbds;
|
||||||
|
|
||||||
|
// https://mirror.codeforces.com/blog/entry/124683
|
||||||
|
|
||||||
|
namespace hashing {
|
||||||
|
using i64 = std::int64_t;
|
||||||
|
using u64 = std::uint64_t;
|
||||||
|
static const u64 FIXED_RANDOM =
|
||||||
|
std::chrono::steady_clock::now().time_since_epoch().count();
|
||||||
|
|
||||||
|
#if USE_AES
|
||||||
|
std::mt19937 rd(FIXED_RANDOM);
|
||||||
|
const __m128i KEY1{(i64)rd(), (i64)rd()};
|
||||||
|
const __m128i KEY2{(i64)rd(), (i64)rd()};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <class T, class D = void>
|
||||||
|
struct custom_hash {};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline void hash_combine(u64 &seed, T const &v) {
|
||||||
|
custom_hash<T> hasher;
|
||||||
|
seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct custom_hash<T,
|
||||||
|
typename std::enable_if<std::is_integral<T>::value>::type> {
|
||||||
|
u64 operator()(T _x) const {
|
||||||
|
u64 x = _x;
|
||||||
|
#if USE_AES
|
||||||
|
__m128i m{i64(u64(x) * 0xbf58476d1ce4e5b9u64), (i64)FIXED_RANDOM};
|
||||||
|
__m128i y = _mm_aesenc_si128(m, KEY1);
|
||||||
|
__m128i z = _mm_aesenc_si128(y, KEY2);
|
||||||
|
return z[0];
|
||||||
|
#else
|
||||||
|
x += 0x9e3779b97f4a7c15 + FIXED_RANDOM;
|
||||||
|
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
|
||||||
|
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
|
||||||
|
return x ^ (x >> 31);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct custom_hash<T, std::void_t<decltype(std::begin(std::declval<T>()))>> {
|
||||||
|
u64 operator()(T const &a) const {
|
||||||
|
u64 value = FIXED_RANDOM;
|
||||||
|
for (auto &x : a)
|
||||||
|
hash_combine(value, x);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class... T>
|
||||||
|
struct custom_hash<std::tuple<T...>> {
|
||||||
|
u64 operator()(const std::tuple<T...> &a) const {
|
||||||
|
u64 value = FIXED_RANDOM;
|
||||||
|
std::apply(
|
||||||
|
[&value](T const &...args) {
|
||||||
|
(hash_combine(value, args), ...);
|
||||||
|
},
|
||||||
|
a);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
struct custom_hash<std::pair<T, U>> {
|
||||||
|
u64 operator()(std::pair<T, U> const &a) const {
|
||||||
|
u64 value = FIXED_RANDOM;
|
||||||
|
hash_combine(value, a.first);
|
||||||
|
hash_combine(value, a.second);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}; // namespace hashing
|
||||||
|
|
||||||
|
#ifdef PB_DS_ASSOC_CNTNR_HPP
|
||||||
|
template <class Key, class Value = null_type>
|
||||||
|
using hashtable = gp_hash_table<
|
||||||
|
Key, Value, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||||
|
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||||
|
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||||
|
hash_load_check_resize_trigger<>, true>>;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ifdef PB_DS_TREE_POLICY_HPP
|
||||||
|
template <typename T>
|
||||||
|
using multitree = tree<T, null_type, std::less_equal<T>, rb_tree_tag,
|
||||||
|
tree_order_statistics_node_update>;
|
||||||
|
template <class Key, class Value = null_type>
|
||||||
|
using rbtree = tree<Key, Value, std::less<Key>, rb_tree_tag,
|
||||||
|
tree_order_statistics_node_update>;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
hashtable<u64> seen;
|
||||||
|
bitset<100000 + 1> dp;
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u64 n;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
if (seen.find(n) != seen.end()) {
|
||||||
|
cout << "YES\n";
|
||||||
|
} else
|
||||||
|
cout << "NO\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
cin.exceptions(cin.failbit);
|
||||||
|
|
||||||
|
int tc = 1;
|
||||||
|
cin >> tc;
|
||||||
|
|
||||||
|
dp[1] = true;
|
||||||
|
seen.insert(1);
|
||||||
|
|
||||||
|
vector<u64> binaries;
|
||||||
|
for (u64 i = 1; i <= 100000; ++i) {
|
||||||
|
u64 I = i;
|
||||||
|
bool good = true;
|
||||||
|
while (I) {
|
||||||
|
if (I % 10 > 1) {
|
||||||
|
good = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
I /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (good)
|
||||||
|
binaries.push_back(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (u64 bin : binaries) {
|
||||||
|
for (u64 j = 1; j * bin <= 100000; ++j) {
|
||||||
|
if (dp[j]) {
|
||||||
|
dp[j * bin] = true;
|
||||||
|
seen.insert(j * bin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
12
codeforces/937/debug_flags.txt
Normal file
12
codeforces/937/debug_flags.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
-g3
|
||||||
|
-fsanitize=address,undefined
|
||||||
|
-fsanitize=float-divide-by-zero
|
||||||
|
-fsanitize=float-cast-overflow
|
||||||
|
-fno-sanitize-recover=all
|
||||||
|
-fstack-protector-all
|
||||||
|
-fstack-usage
|
||||||
|
-fno-omit-frame-pointer
|
||||||
|
-fno-inline
|
||||||
|
-ffunction-sections
|
||||||
|
-D_GLIBCXX_DEBUG
|
||||||
|
-D_GLIBCXX_DEBUG_PEDANTIC
|
||||||
70
codeforces/937/e.cc
Normal file
70
codeforces/937/e.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;
|
||||||
|
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 n;
|
||||||
|
cin >> n;
|
||||||
|
string s;
|
||||||
|
cin >> s;
|
||||||
|
u64 ans = n;
|
||||||
|
for (u32 i = 1; i < n; ++i) {
|
||||||
|
if (n % i) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
unordered_map<string, int> seen;
|
||||||
|
bool bad = false;
|
||||||
|
for (u32 j = 0; j < n; j += i) {
|
||||||
|
++seen[s.substr(j, i)];
|
||||||
|
if (seen.size() > 2) {
|
||||||
|
bad = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bad)
|
||||||
|
continue;
|
||||||
|
if (seen.size() == 1) {
|
||||||
|
ans = i;
|
||||||
|
break;
|
||||||
|
} else if (seen.size() == 2) {
|
||||||
|
int first = seen.begin()->second, second = next(seen.begin())->second;
|
||||||
|
int diff = 0;
|
||||||
|
for (u32 j = 0; j < seen.begin()->first.size(); ++j) {
|
||||||
|
diff += seen.begin()->first[j] != next(seen.begin())->first[j];
|
||||||
|
}
|
||||||
|
if ((first == 1 || second == 1) && diff <= 1) {
|
||||||
|
ans = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << ans << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
cin.exceptions(cin.failbit);
|
||||||
|
|
||||||
|
int tc = 1;
|
||||||
|
cin >> tc;
|
||||||
|
|
||||||
|
for (int t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
73
codeforces/937/f.cc
Normal file
73
codeforces/937/f.cc
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
#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;
|
||||||
|
|
||||||
|
using i32 = int32_t;
|
||||||
|
using u32 = uint32_t;
|
||||||
|
using i64 = int64_t;
|
||||||
|
using u64 = uint64_t;
|
||||||
|
using f64 = double;
|
||||||
|
using f128 = long double;
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u64 a, b, c;
|
||||||
|
cin >> a >> b >> c;
|
||||||
|
|
||||||
|
u64 depth = 0;
|
||||||
|
u64 to_take = 1;
|
||||||
|
|
||||||
|
// NOTE :look at prev wrong submissions; full tree assumptions, when u can
|
||||||
|
// have b on last layer this should be oe of ur first observatoins
|
||||||
|
while (to_take && (a > 0 || b > 0 || c > 0)) {
|
||||||
|
++depth;
|
||||||
|
u64 next_to_take = 0;
|
||||||
|
|
||||||
|
auto take = min(a, to_take);
|
||||||
|
a -= take;
|
||||||
|
next_to_take = 2 * take;
|
||||||
|
to_take -= take;
|
||||||
|
|
||||||
|
take = min(b, to_take);
|
||||||
|
b -= take;
|
||||||
|
to_take -= take;
|
||||||
|
next_to_take += take;
|
||||||
|
|
||||||
|
take = min(c, to_take);
|
||||||
|
c -= take;
|
||||||
|
to_take -= take;
|
||||||
|
|
||||||
|
if (to_take != 0) {
|
||||||
|
cout << -1 << '\n';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
to_take = next_to_take;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to_take > 0 || a > 0 || b > 0 || c > 0) {
|
||||||
|
cout << -1 << '\n';
|
||||||
|
} else {
|
||||||
|
cout << depth - 1 << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { // {{{
|
||||||
|
cin.tie(nullptr)->sync_with_stdio(false);
|
||||||
|
cin.exceptions(cin.failbit);
|
||||||
|
|
||||||
|
int tc = 1;
|
||||||
|
cin >> tc;
|
||||||
|
|
||||||
|
for (int t = 0; t < tc; ++t) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
8
codeforces/937/io/a.in
Normal file
8
codeforces/937/io/a.in
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
7
|
||||||
|
1 2 3
|
||||||
|
3 2 1
|
||||||
|
1 5 3
|
||||||
|
3 4 1
|
||||||
|
0 0 0
|
||||||
|
4 1 7
|
||||||
|
4 5 7
|
||||||
10
codeforces/937/io/a.out
Normal file
10
codeforces/937/io/a.out
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
STAIR
|
||||||
|
NONE
|
||||||
|
PEAK
|
||||||
|
PEAK
|
||||||
|
NONE
|
||||||
|
NONE
|
||||||
|
STAIR
|
||||||
|
|
||||||
|
[code]: 0
|
||||||
|
[time]: 10.5526 ms
|
||||||
5
codeforces/937/io/b.in
Normal file
5
codeforces/937/io/b.in
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
4
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
23
codeforces/937/io/b.out
Normal file
23
codeforces/937/io/b.out
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
##
|
||||||
|
##
|
||||||
|
##..
|
||||||
|
##..
|
||||||
|
..##
|
||||||
|
..##
|
||||||
|
##..##
|
||||||
|
##..##
|
||||||
|
..##..
|
||||||
|
..##..
|
||||||
|
##..##
|
||||||
|
##..##
|
||||||
|
##..##..
|
||||||
|
##..##..
|
||||||
|
..##..##
|
||||||
|
..##..##
|
||||||
|
##..##..
|
||||||
|
##..##..
|
||||||
|
..##..##
|
||||||
|
..##..##
|
||||||
|
|
||||||
|
[code]: 0
|
||||||
|
[time]: 11.0681 ms
|
||||||
12
codeforces/937/io/c.in
Normal file
12
codeforces/937/io/c.in
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
11
|
||||||
|
09:41
|
||||||
|
18:06
|
||||||
|
12:14
|
||||||
|
00:59
|
||||||
|
00:00
|
||||||
|
14:34
|
||||||
|
01:01
|
||||||
|
19:07
|
||||||
|
11:59
|
||||||
|
12:00
|
||||||
|
21:37
|
||||||
14
codeforces/937/io/c.out
Normal file
14
codeforces/937/io/c.out
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
09:41 AM
|
||||||
|
06:06 PM
|
||||||
|
12:14 PM
|
||||||
|
12:59 AM
|
||||||
|
12:00 AM
|
||||||
|
02:34 PM
|
||||||
|
01:01 AM
|
||||||
|
07:07 PM
|
||||||
|
11:59 AM
|
||||||
|
12:00 PM
|
||||||
|
09:37 PM
|
||||||
|
|
||||||
|
[code]: 0
|
||||||
|
[time]: 4.08173 ms
|
||||||
12
codeforces/937/io/d.in
Normal file
12
codeforces/937/io/d.in
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
11
|
||||||
|
121
|
||||||
|
1
|
||||||
|
14641
|
||||||
|
12221
|
||||||
|
10110
|
||||||
|
100000
|
||||||
|
99
|
||||||
|
112
|
||||||
|
2024
|
||||||
|
12421
|
||||||
|
1001
|
||||||
14
codeforces/937/io/d.out
Normal file
14
codeforces/937/io/d.out
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
YES
|
||||||
|
YES
|
||||||
|
YES
|
||||||
|
YES
|
||||||
|
YES
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
NO
|
||||||
|
NO
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
|
||||||
|
[code]: 0
|
||||||
|
[time]: 12.0294 ms
|
||||||
11
codeforces/937/io/e.in
Normal file
11
codeforces/937/io/e.in
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
5
|
||||||
|
4
|
||||||
|
abaa
|
||||||
|
4
|
||||||
|
abba
|
||||||
|
13
|
||||||
|
slavicgslavic
|
||||||
|
8
|
||||||
|
hshahaha
|
||||||
|
20
|
||||||
|
stormflamestornflame
|
||||||
8
codeforces/937/io/e.out
Normal file
8
codeforces/937/io/e.out
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
1
|
||||||
|
4
|
||||||
|
13
|
||||||
|
2
|
||||||
|
10
|
||||||
|
|
||||||
|
[code]: 0
|
||||||
|
[time]: 12.5105 ms
|
||||||
2
codeforces/937/io/f.in
Normal file
2
codeforces/937/io/f.in
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
1
|
||||||
|
2 1 3
|
||||||
4
codeforces/937/io/f.out
Normal file
4
codeforces/937/io/f.out
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
2
|
||||||
|
|
||||||
|
[code]: 0
|
||||||
|
[time]: 11.7621 ms
|
||||||
28
codeforces/937/makefile
Normal file
28
codeforces/937/makefile
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
.PHONY: run debug clean setup init
|
||||||
|
|
||||||
|
SRC = $(word 2,$(MAKECMDGOALS))
|
||||||
|
|
||||||
|
.SILENT:
|
||||||
|
|
||||||
|
run:
|
||||||
|
sh scripts/run.sh $(SRC)
|
||||||
|
|
||||||
|
debug:
|
||||||
|
sh scripts/debug.sh $(SRC)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build/*
|
||||||
|
|
||||||
|
setup:
|
||||||
|
test -d build || mkdir -p build
|
||||||
|
test -d io || mkdir -p io
|
||||||
|
test -d scripts || mkdir -p scripts
|
||||||
|
test -f compile_flags.txt || cp $(HOME)/.config/cp-template/compile_flags.txt .
|
||||||
|
test -f .clangd || cp $(HOME)/.config/cp-template/.clangd .
|
||||||
|
test -f .clang-format || cp $(HOME)/.config/cp-template/.clang-format .
|
||||||
|
|
||||||
|
init:
|
||||||
|
make setup
|
||||||
|
|
||||||
|
%:
|
||||||
|
@:
|
||||||
29
codeforces/937/scripts/debug.sh
Normal file
29
codeforces/937/scripts/debug.sh
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ./scripts/utils.sh
|
||||||
|
|
||||||
|
SRC="$1"
|
||||||
|
BASE=$(basename "$SRC" .cc)
|
||||||
|
INPUT="${BASE}.in"
|
||||||
|
OUTPUT="${BASE}.out"
|
||||||
|
DBG_BIN="${BASE}.debug"
|
||||||
|
|
||||||
|
test -d build || mkdir -p build
|
||||||
|
test -d io || mkdir -p io
|
||||||
|
|
||||||
|
test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/"
|
||||||
|
test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/"
|
||||||
|
|
||||||
|
test -f "io/$INPUT" || touch "io/$INPUT"
|
||||||
|
test -f "io/$OUTPUT" || touch "io/$OUTPUT"
|
||||||
|
|
||||||
|
INPUT="io/$INPUT"
|
||||||
|
OUTPUT="io/$OUTPUT"
|
||||||
|
DBG_BIN="build/$DBG_BIN"
|
||||||
|
|
||||||
|
compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt
|
||||||
|
CODE=$?
|
||||||
|
test $CODE -gt 0 && exit $CODE
|
||||||
|
|
||||||
|
execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT"
|
||||||
|
exit $?
|
||||||
29
codeforces/937/scripts/run.sh
Normal file
29
codeforces/937/scripts/run.sh
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ./scripts/utils.sh
|
||||||
|
|
||||||
|
SRC="$1"
|
||||||
|
BASE=$(basename "$SRC" .cc)
|
||||||
|
INPUT="${BASE}.in"
|
||||||
|
OUTPUT="${BASE}.out"
|
||||||
|
RUN_BIN="${BASE}.run"
|
||||||
|
|
||||||
|
test -d build || mkdir -p build
|
||||||
|
test -d io || mkdir -p io
|
||||||
|
|
||||||
|
test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/"
|
||||||
|
test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/"
|
||||||
|
|
||||||
|
test -f "io/$INPUT" || touch "io/$INPUT"
|
||||||
|
test -f "io/$OUTPUT" || touch "io/$OUTPUT"
|
||||||
|
|
||||||
|
INPUT="io/$INPUT"
|
||||||
|
OUTPUT="io/$OUTPUT"
|
||||||
|
RUN_BIN="build/$RUN_BIN"
|
||||||
|
|
||||||
|
compile_source "$SRC" "$RUN_BIN" "$OUTPUT" ""
|
||||||
|
CODE=$?
|
||||||
|
test $CODE -gt 0 && exit $CODE
|
||||||
|
|
||||||
|
execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT"
|
||||||
|
exit $?
|
||||||
53
codeforces/937/scripts/utils.sh
Normal file
53
codeforces/937/scripts/utils.sh
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
execute_binary() {
|
||||||
|
binary="$1"
|
||||||
|
input="$2"
|
||||||
|
output="$3"
|
||||||
|
|
||||||
|
start=$(date '+%s.%N')
|
||||||
|
timeout 2s ./"$binary" <"$input" >"$output" 2>&1
|
||||||
|
CODE=$?
|
||||||
|
end=$(date '+%s.%N')
|
||||||
|
truncate -s "$(head -n 1000 "$output" | wc -c)" "$output"
|
||||||
|
|
||||||
|
if [ $CODE -ge 124 ]; then
|
||||||
|
MSG=''
|
||||||
|
case $CODE in
|
||||||
|
124) MSG='TIMEOUT' ;;
|
||||||
|
128) MSG='SIGILL' ;;
|
||||||
|
130) MSG='SIGABRT' ;;
|
||||||
|
131) MSG='SIGBUS' ;;
|
||||||
|
136) MSG='SIGFPE' ;;
|
||||||
|
135) MSG='SIGSEGV' ;;
|
||||||
|
137) MSG='SIGPIPE' ;;
|
||||||
|
139) MSG='SIGTERM' ;;
|
||||||
|
esac
|
||||||
|
[ $CODE -ne 124 ] && sed -i '$d' "$output"
|
||||||
|
test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output"
|
||||||
|
else
|
||||||
|
printf '\n[code]: %s' "$CODE" >>"$output"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output
|
||||||
|
return $CODE
|
||||||
|
}
|
||||||
|
|
||||||
|
compile_source() {
|
||||||
|
src="$1"
|
||||||
|
bin="$2"
|
||||||
|
output="$3"
|
||||||
|
flags="$4"
|
||||||
|
|
||||||
|
test -f "$bin" && rm "$bin" || true
|
||||||
|
g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output"
|
||||||
|
CODE=$?
|
||||||
|
|
||||||
|
if [ $CODE -gt 0 ]; then
|
||||||
|
printf '\n[code]: %s' "$CODE" >>"$output"
|
||||||
|
return $CODE
|
||||||
|
else
|
||||||
|
echo '' >"$output"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue