From bd81f1744daeaf597f66c2ccdb9e5851983e8920 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 8 Dec 2025 19:01:14 -0600 Subject: [PATCH] some more problems --- codeforces/923/a.cc | 13 ++++- codeforces/946/.clang-format | 11 ++-- codeforces/946/.clangd | 37 ------------- codeforces/946/a.cc | 91 -------------------------------- codeforces/946/compile_flags.txt | 31 ----------- codeforces/946/debug_flags.txt | 14 ----- codeforces/946/io/a.in | 0 codeforces/946/io/a.out | 0 codeforces/946/makefile | 30 ----------- codeforces/946/scripts/debug.sh | 29 ---------- codeforces/946/scripts/run.sh | 29 ---------- codeforces/946/scripts/utils.sh | 61 --------------------- 12 files changed, 15 insertions(+), 331 deletions(-) delete mode 100644 codeforces/946/.clangd delete mode 100644 codeforces/946/a.cc delete mode 100644 codeforces/946/compile_flags.txt delete mode 100644 codeforces/946/debug_flags.txt delete mode 100644 codeforces/946/io/a.in delete mode 100644 codeforces/946/io/a.out delete mode 100644 codeforces/946/makefile delete mode 100644 codeforces/946/scripts/debug.sh delete mode 100644 codeforces/946/scripts/run.sh delete mode 100644 codeforces/946/scripts/utils.sh diff --git a/codeforces/923/a.cc b/codeforces/923/a.cc index b9a7e78..6d50823 100644 --- a/codeforces/923/a.cc +++ b/codeforces/923/a.cc @@ -92,7 +92,18 @@ void NO() { static constexpr int MOD = 1e9 + 7; void solve() { - println("HI"); + int n; + string s; + cin >> n; + cin >> s; + int l = -1, r; + for (int i = 0; i < n; ++i) { + if (s[i] == 'B') { + if (l == -1) l = i; + r = i; + } + } + cout << r - l + 1 << '\n'; } int main() { diff --git a/codeforces/946/.clang-format b/codeforces/946/.clang-format index e7350c4..cbec8b9 100644 --- a/codeforces/946/.clang-format +++ b/codeforces/946/.clang-format @@ -1,9 +1,4 @@ BasedOnStyle: Google -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortCompoundRequirementOnASingleLine: false -AllowShortEnumsOnASingleLine: false -AllowShortFunctionsOnASingleLine: false -AllowShortIfStatementsOnASingleLine: false -AllowShortLambdasOnASingleLine: false -AllowShortLoopsOnASingleLine: false +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/946/.clangd b/codeforces/946/.clangd deleted file mode 100644 index b77a15b..0000000 --- a/codeforces/946/.clangd +++ /dev/null @@ -1,37 +0,0 @@ -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 - -Wno-unknown-pragmas --e -std=c++23 --e -std=c++23 --e -std=c++23 --e -std=c++23 diff --git a/codeforces/946/a.cc b/codeforces/946/a.cc deleted file mode 100644 index 2157817..0000000 --- a/codeforces/946/a.cc +++ /dev/null @@ -1,91 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -// 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; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); - -template -[[nodiscard]] static T sc(auto&& x) { - return static_cast(x); -} - -template -[[nodiscard]] static T sz(auto&& x) { - return static_cast(x.size()); -} -#endif - -static void NO() { - std::cout << "NO\n"; -} - -static void YES() { - std::cout << "YES\n"; -} - -template -using vec = std::vector; - -#define all(x) (x).begin(), (x).end() -#define rall(x) (x).rbegin(), (x).rend() -#define ff first -#define ss second - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); - -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - - u32 tc = 1; - std::cin >> tc; - - for (u32 t = 0; t < tc; ++t) { - solve(); - } - - return 0; -} -// }}} diff --git a/codeforces/946/compile_flags.txt b/codeforces/946/compile_flags.txt deleted file mode 100644 index 17821f8..0000000 --- a/codeforces/946/compile_flags.txt +++ /dev/null @@ -1,31 +0,0 @@ --pedantic-errors --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 --Wmisleading-indentation --Wduplicated-cond --Wduplicated-branches --Wlogical-op --Wnull-dereference --Wformat=2 --Wformat-overflow --Wformat-truncation --Wdouble-promotion --Wundef --DLOCAL --std=c++23 diff --git a/codeforces/946/debug_flags.txt b/codeforces/946/debug_flags.txt deleted file mode 100644 index 62a0135..0000000 --- a/codeforces/946/debug_flags.txt +++ /dev/null @@ -1,14 +0,0 @@ --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 --DLOCAL --std=c++23 diff --git a/codeforces/946/io/a.in b/codeforces/946/io/a.in deleted file mode 100644 index e69de29..0000000 diff --git a/codeforces/946/io/a.out b/codeforces/946/io/a.out deleted file mode 100644 index e69de29..0000000 diff --git a/codeforces/946/makefile b/codeforces/946/makefile deleted file mode 100644 index 3c50267..0000000 --- a/codeforces/946/makefile +++ /dev/null @@ -1,30 +0,0 @@ -.PHONY: run debug clean setup init - -VERSION ?= 20 - -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 .clang-format || cp $(HOME)/.config/cp-template/.clang-format . - test -f compile_flags.txt || cp $(HOME)/.config/cp-template/compile_flags.txt . && echo -std=c++$(VERSION) >>compile_flags.txt - test -f .clangd || cp $(HOME)/.config/cp-template/.clangd . && echo -e "\t\t-std=c++$(VERSION)" >>.clangd - -init: - make setup - -%: - @: diff --git a/codeforces/946/scripts/debug.sh b/codeforces/946/scripts/debug.sh deleted file mode 100644 index 1e63f37..0000000 --- a/codeforces/946/scripts/debug.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/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" true -exit $? diff --git a/codeforces/946/scripts/run.sh b/codeforces/946/scripts/run.sh deleted file mode 100644 index ab9aa7d..0000000 --- a/codeforces/946/scripts/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/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 $? diff --git a/codeforces/946/scripts/utils.sh b/codeforces/946/scripts/utils.sh deleted file mode 100644 index e4cf8f8..0000000 --- a/codeforces/946/scripts/utils.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -execute_binary() { - binary="$1" - input="$2" - output="$3" - is_debug="$4" - - start=$(date '+%s.%N') - if [ -n "$is_debug" ]; then - asan="$(ldconfig -p | grep libasan.so | head -n1 | awk '{print $4}')" - LD_PRELOAD="$asan" timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - else - timeout 2s ./"$binary" <"$input" >"$output" 2>&1 - fi - 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 - test -n "$is_debug" && is_debug_string=true || is_debug_string=false - printf '\n[debug]: %s' "$is_debug_string" >>$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 -}