Compare commits
9 Commits
b3cd28471e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| bc1489d320 | |||
| cfb65a4c2d | |||
| 8f0ec6cead | |||
| be454e4420 | |||
| b4dff1d344 | |||
| 3e69d7713e | |||
| d1720c1567 | |||
| d6777983a1 | |||
| cac746a69c |
17
run.py
17
run.py
@@ -383,7 +383,7 @@ class StorageManager:
|
||||
) -> None:
|
||||
path = STORAGE_DIR / location / lang.value / ("completed" if completed else "")
|
||||
os.makedirs(path, exist_ok=True)
|
||||
with open(f"{path}/{filename}", "wb") as f:
|
||||
with open(path / f"{filename}.{lang.value}", "wb") as f:
|
||||
f.write(content)
|
||||
|
||||
def read_file(self, location: str, lang: Language, filename: str) -> bytes:
|
||||
@@ -392,8 +392,8 @@ class StorageManager:
|
||||
raise FileNotFoundError(
|
||||
f"File not found in storage: {location}/{filename}.{lang.value}"
|
||||
)
|
||||
file_path = f"{path}/{filename}"
|
||||
if not os.path.isfile(file_path):
|
||||
file_path = path / f"{filename}.{lang.value}"
|
||||
if not file_path.is_file():
|
||||
raise FileNotFoundError(f"File not found in storage: {file_path}")
|
||||
with open(file_path, "rb") as f:
|
||||
return f.read()
|
||||
@@ -586,7 +586,7 @@ def create(target: str, completed: bool, no_template: bool, force: bool):
|
||||
click.secho(f"Template not found: {template_path}", fg="yellow")
|
||||
|
||||
StorageManager().save_file(
|
||||
loc, lang, f"{filename}.{lang.value}", content, completed
|
||||
loc, lang, filename, content, completed
|
||||
)
|
||||
click.secho(
|
||||
f"Created '{filename}.{lang.value}' in location '{loc}'",
|
||||
@@ -644,12 +644,10 @@ def run(lang: str, testcase: tuple[str, ...], verbose: bool):
|
||||
f_in_path = f"{TC_DIR}/{tc}.in"
|
||||
f_out_path = f"{TC_DIR}/{tc}.out"
|
||||
|
||||
with (
|
||||
open(f_in_path, "r", encoding="utf-8") as f_in,
|
||||
open(f_out_path, "r", encoding="utf-8") as f_out,
|
||||
):
|
||||
with open(f_out_path, "r", encoding="utf-8") as f_out:
|
||||
expected = f_out.read().strip()
|
||||
|
||||
f_in = open(f_in_path, "r", encoding="utf-8")
|
||||
proc = subprocess.Popen(
|
||||
target_language.executable_command,
|
||||
stdin=f_in,
|
||||
@@ -663,6 +661,7 @@ def run(lang: str, testcase: tuple[str, ...], verbose: bool):
|
||||
print(line, end="")
|
||||
|
||||
stdout, stderr = proc.communicate()
|
||||
f_in.close()
|
||||
|
||||
if proc.returncode != 0:
|
||||
click.secho(">>>>>> [RUN TIME ERROR] >>>>>>", fg="red", bold=True)
|
||||
@@ -768,7 +767,7 @@ def export(from_: tuple[str, ...], all_: bool, force: bool):
|
||||
|
||||
with open(src_path, "rb") as f_src:
|
||||
content = f_src.read()
|
||||
|
||||
os.remove(src_path)
|
||||
StorageManager().save_file(
|
||||
s_loc, from_language, s_file, content, s_is_completed
|
||||
)
|
||||
|
||||
103
storage/contest/cpp/2026-kaist-run-spring-1.cpp
Normal file
103
storage/contest/cpp/2026-kaist-run-spring-1.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#define let auto
|
||||
#define fn auto
|
||||
#define usize size_t
|
||||
using namespace std;
|
||||
|
||||
#define UD 1'000'000
|
||||
|
||||
fn fastio() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
}
|
||||
|
||||
fn main() -> int {
|
||||
fastio();
|
||||
usize n, m;
|
||||
cin >> n >> m;
|
||||
|
||||
let arr = new usize[5 * m];
|
||||
|
||||
let music = new usize[n];
|
||||
let cnts = new usize[n];
|
||||
for (usize i = 0; i < n; i++) {
|
||||
music[i] = UD;
|
||||
cnts[i] = 0;
|
||||
}
|
||||
|
||||
for (usize i = 0; i < m; i++) {
|
||||
for (usize j = 0; j < 4; j++) {
|
||||
cin >> arr[5 * i + j];// idx
|
||||
arr[5 * i + j] -= 1;
|
||||
cnts[arr[5 * i + j]]++;
|
||||
}
|
||||
cin >> arr[5 * i + 4];
|
||||
}
|
||||
|
||||
let cntv = vector<pair<usize, usize>>();
|
||||
for (usize i = 0; i < n; i++) {
|
||||
cntv.push_back(pair(cnts[i], i));
|
||||
}
|
||||
|
||||
sort(cntv.begin(), cntv.end());
|
||||
reverse(cntv.begin(), cntv.end());
|
||||
|
||||
usize tot = 0;
|
||||
usize before = 0;
|
||||
for (let it = cntv.begin(); it < cntv.end(); it++) {
|
||||
if (tot > 3 * m) {
|
||||
music[before] = UD;
|
||||
break;
|
||||
} else if (tot == 3 * m) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
tot += it->first;
|
||||
music[it->second] = 0;
|
||||
before = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
for (usize i = 0; i < m; i++) {
|
||||
let x = arr[5 * i + 0];
|
||||
let y = arr[5 * i + 1];
|
||||
let z = arr[5 * i + 2];
|
||||
let w = arr[5 * i + 3];
|
||||
let k = arr[5 * i + 4];
|
||||
let mx = music[x];
|
||||
let my = music[y];
|
||||
let mz = music[z];
|
||||
let mw = music[w];
|
||||
let key = (mx % 4 + my % 4 + mz % 4 + mw % 4) % 4;
|
||||
if ((mx + my + mz + mw) / UD == 1) {
|
||||
if (mx == UD) {
|
||||
music[x] = (k + 4 - key) % 4;
|
||||
} else if (my == UD) {
|
||||
music[y] = (k + 4 - key) % 4;
|
||||
} else if (mz == UD) {
|
||||
music[z] = (k + 4 - key) % 4;
|
||||
} else {
|
||||
music[w] = (k + 4 - key) % 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (usize i = 0; i < n; i++) {
|
||||
if (music[i] == UD) {
|
||||
music[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (usize i = 0; i < n; i++) {
|
||||
cout << music[i] << " ";
|
||||
}
|
||||
|
||||
delete[] arr;
|
||||
delete[] music;
|
||||
delete[] cnts;
|
||||
|
||||
return 0;
|
||||
}
|
||||
36
storage/contest/cpp/2026-kaist-run-spring-2.cpp
Normal file
36
storage/contest/cpp/2026-kaist-run-spring-2.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#define let auto
|
||||
#define fn auto
|
||||
#define usize size_t
|
||||
using namespace std;
|
||||
|
||||
fn fastio() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
}
|
||||
|
||||
fn main() -> int {
|
||||
fastio();
|
||||
usize r, u, n;
|
||||
cin >> r >> u >> n;
|
||||
|
||||
usize cnt = r * u;
|
||||
if (n <= 10) {
|
||||
usize fibn = 2;
|
||||
usize fibns1 = 1;
|
||||
usize fibns2 = 1;
|
||||
|
||||
for (usize i = 3; i < n; i++) {
|
||||
fibns2 = fibns1;
|
||||
fibns1 = fibn;
|
||||
fibn = fibns2 + fibns1;
|
||||
}
|
||||
usize delta = ((u - 1) * fibns1 + (r - 1) * fibns2);
|
||||
cout << delta / fibns1 + delta / fibns2 - (delta / (fibns1 * fibns2)) + 1 << endl;
|
||||
} else {
|
||||
cout << cnt << endl;
|
||||
}
|
||||
}
|
||||
80
storage/contest/cpp/2026-kaist-run-spring-4.cpp
Normal file
80
storage/contest/cpp/2026-kaist-run-spring-4.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
#define let auto
|
||||
#define fn auto
|
||||
#define usize size_t
|
||||
|
||||
#define UMAX 0xfffffff
|
||||
|
||||
using namespace std;
|
||||
|
||||
fn fastio() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
}
|
||||
|
||||
struct Fire {
|
||||
usize f;
|
||||
usize v;
|
||||
};
|
||||
|
||||
fn main() -> int {
|
||||
fastio();
|
||||
let _comp = [](Fire &a, const Fire &b) { return a.f < b.f; };
|
||||
usize n, m;
|
||||
cin >> n >> m;
|
||||
|
||||
let fs = vector<Fire>(n);
|
||||
let bs = vector<usize>(m);
|
||||
|
||||
for (usize i = 0; i < n; i++) {
|
||||
cin >> fs[i].f;
|
||||
cin >> fs[i].v;
|
||||
}
|
||||
|
||||
sort(fs.begin(), fs.end(), _comp);
|
||||
|
||||
for (usize i = 0; i < m; i++) {
|
||||
cin >> bs[i];
|
||||
}
|
||||
|
||||
// 1pass
|
||||
usize last = UMAX;
|
||||
let vfx = vector<usize>();
|
||||
for (usize i = 0; i < m; i++) {
|
||||
let t = bs[i];
|
||||
|
||||
Fire tf = {
|
||||
.f = t,
|
||||
.v = 0,
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (last == UMAX) {
|
||||
last = m;
|
||||
}
|
||||
|
||||
// 2pass
|
||||
sort(vfx.begin(), vfx.end());
|
||||
let heap = priority_queue<usize>();
|
||||
usize total_v = 0;
|
||||
while (vfx.size() > 0) {
|
||||
let key = *(vfx.end() - 1);
|
||||
vfx.pop_back();
|
||||
while (fs.size() > 0 && (fs.end() - 1)->f >= key) {
|
||||
heap.push((fs.end() - 1)->v);
|
||||
fs.pop_back();
|
||||
}
|
||||
|
||||
total_v += heap.top();
|
||||
heap.pop();
|
||||
}
|
||||
|
||||
cout << last << " " << total_v << endl;
|
||||
}
|
||||
13
storage/jungol/rs/completed/1000.rs
Normal file
13
storage/jungol/rs/completed/1000.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use std::io::{read_to_string, stdin};
|
||||
|
||||
fn main() {
|
||||
let temp = read_to_string(stdin()).unwrap();
|
||||
let mut iter = temp
|
||||
.split_ascii_whitespace()
|
||||
.map(|x| x.parse::<usize>().unwrap());
|
||||
|
||||
let a = iter.next().unwrap();
|
||||
let b = iter.next().unwrap();
|
||||
|
||||
println!("{}", a + b);
|
||||
}
|
||||
113
storage/ojuz/cpp/completed/KAISTRUN26SPRING_A.cpp
Normal file
113
storage/ojuz/cpp/completed/KAISTRUN26SPRING_A.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#define let auto
|
||||
#define fn auto
|
||||
#define usize size_t
|
||||
using u32 = uint32_t;
|
||||
using namespace std;
|
||||
|
||||
const u32 KX = 123456789;
|
||||
const u32 KY = 362436069;
|
||||
const u32 KZ = 521288629;
|
||||
const u32 KW = 88675123;
|
||||
|
||||
fn fastio() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
}
|
||||
|
||||
struct Rand {
|
||||
u32 x, y, z, w;
|
||||
|
||||
static Rand new_seed(u32 seed) {
|
||||
return {KX ^ seed, KY ^ seed, KZ, KW};
|
||||
}
|
||||
|
||||
u32 rand() {
|
||||
u32 t = x ^ (x << 11);
|
||||
x = y;
|
||||
y = z;
|
||||
z = w;
|
||||
w ^= (w >> 19) ^ t ^ (t >> 8);
|
||||
return w;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void shuffle(vector<T>& a) {
|
||||
if (a.empty()) return;
|
||||
usize i = a.size() - 1;
|
||||
while (i > 0) {
|
||||
usize j = rand() % (i + 1);
|
||||
swap(a[i], a[j]);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
u32 rand_range(u32 a, u32 b) {
|
||||
u32 m = b - a + 1;
|
||||
return a + rand() % m;
|
||||
}
|
||||
|
||||
double rand_float() {
|
||||
return static_cast<double>(rand()) / static_cast<double>((u32)-1);
|
||||
}
|
||||
};
|
||||
|
||||
fn main() -> int {
|
||||
fastio();
|
||||
|
||||
istreambuf_iterator<char> it(cin), end;
|
||||
string temp(it, end);
|
||||
vector<u32> vals;
|
||||
usize pos = 0;
|
||||
while (pos < temp.size()) {
|
||||
while (pos < temp.size() && isspace(temp[pos])) pos++;
|
||||
if (pos >= temp.size()) break;
|
||||
usize start = pos;
|
||||
while (pos < temp.size() && !isspace(temp[pos])) pos++;
|
||||
vals.push_back(stoul(temp.substr(start, pos - start)));
|
||||
}
|
||||
|
||||
auto it2 = vals.begin();
|
||||
u32 n = *it2++;
|
||||
u32 m = *it2++;
|
||||
|
||||
vector<tuple<u32, u32, u32, u32, u32>> requests;
|
||||
for (u32 i = 0; i < m; i++) {
|
||||
u32 w = *it2++ - 1;
|
||||
u32 x = *it2++ - 1;
|
||||
u32 y = *it2++ - 1;
|
||||
u32 z = *it2++ - 1;
|
||||
u32 k = *it2++;
|
||||
requests.emplace_back(w, x, y, z, k);
|
||||
}
|
||||
|
||||
u32 trial = 0;
|
||||
while (true) {
|
||||
Rand rand = Rand::new_seed(trial);
|
||||
vector<u32> music(n);
|
||||
for (u32 i = 0; i < n; i++) {
|
||||
music[i] = rand.rand_range(0, 3);
|
||||
}
|
||||
|
||||
u32 cnt = 0;
|
||||
for (const auto& req : requests) {
|
||||
u32 w, x, y, z, k;
|
||||
tie(w, x, y, z, k) = req;
|
||||
if ((music[w] + music[x] + music[y] + music[z]) % 4 == k) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
if (m / 4 <= cnt) {
|
||||
for (u32 a : music) {
|
||||
cout << a << ' ';
|
||||
}
|
||||
break;
|
||||
}
|
||||
trial++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user