Skip to content

Commit

Permalink
s2024 archive
Browse files Browse the repository at this point in the history
  • Loading branch information
szhanggg committed Jun 12, 2024
1 parent fe43ed6 commit 80e5d3f
Show file tree
Hide file tree
Showing 34 changed files with 1,923 additions and 0 deletions.
Binary file added archive/2024s/advanced.pdf
Binary file not shown.
Binary file added archive/2024s/advanced_editorial.pdf
Binary file not shown.
102 changes: 102 additions & 0 deletions archive/2024s/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!doctype html>
<html lang="en">
<head>
<title>mBIT</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" href="/style.css">
</head>
<body>
<div class="notification-top notification is-primary">
mBIT will be hosting the Spring 2024 In-Person and Virtual Round on June 8th! <a href="https://docs.google.com/forms/d/1xuxpRnFR-uMXdiX2p-1oTutfz6PXqIBbLNzJyI6tfqY/edit">Registration is now open!</a>
</div>
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<div class="navbar-item"><a class="button" href="/"><span class="has-text-primary">m</span>BIT</a></div>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbar">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbar" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" href="/logistics">Logistics</a>
<a class="navbar-item" href="/rules">Rules</a>
<a class="navbar-item" href="/about">About</a>
<a class="navbar-item" href="/schedule">Schedule</a>
<a class="navbar-item" href="/archive">Archive</a>
</div>

<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<svg xmlns="http://www.w3.org/2000/svg" width="35" height="35" fill="red" class="bi bi-instagram" viewBox="0 0 35 35">
<path d="M8 0C5.829 0 5.556.01 4.703.048 3.85.088 3.269.222 2.76.42a3.9 3.9 0 0 0-1.417.923A3.9 3.9 0 0 0 .42 2.76C.222 3.268.087 3.85.048 4.7.01 5.555 0 5.827 0 8.001c0 2.172.01 2.444.048 3.297.04.852.174 1.433.372 1.942.205.526.478.972.923 1.417.444.445.89.719 1.416.923.51.198 1.09.333 1.942.372C5.555 15.99 5.827 16 8 16s2.444-.01 3.298-.048c.851-.04 1.434-.174 1.943-.372a3.9 3.9 0 0 0 1.416-.923c.445-.445.718-.891.923-1.417.197-.509.332-1.09.372-1.942C15.99 10.445 16 10.173 16 8s-.01-2.445-.048-3.299c-.04-.851-.175-1.433-.372-1.941a3.9 3.9 0 0 0-.923-1.417A3.9 3.9 0 0 0 13.24.42c-.51-.198-1.092-.333-1.943-.372C10.443.01 10.172 0 7.998 0zm-.717 1.442h.718c2.136 0 2.389.007 3.232.046.78.035 1.204.166 1.486.275.373.145.64.319.92.599s.453.546.598.92c.11.281.24.705.275 1.485.039.843.047 1.096.047 3.231s-.008 2.389-.047 3.232c-.035.78-.166 1.203-.275 1.485a2.5 2.5 0 0 1-.599.919c-.28.28-.546.453-.92.598-.28.11-.704.24-1.485.276-.843.038-1.096.047-3.232.047s-2.39-.009-3.233-.047c-.78-.036-1.203-.166-1.485-.276a2.5 2.5 0 0 1-.92-.598 2.5 2.5 0 0 1-.6-.92c-.109-.281-.24-.705-.275-1.485-.038-.843-.046-1.096-.046-3.233s.008-2.388.046-3.231c.036-.78.166-1.204.276-1.486.145-.373.319-.64.599-.92s.546-.453.92-.598c.282-.11.705-.24 1.485-.276.738-.034 1.024-.044 2.515-.045zm4.988 1.328a.96.96 0 1 0 0 1.92.96.96 0 0 0 0-1.92m-4.27 1.122a4.109 4.109 0 1 0 0 8.217 4.109 4.109 0 0 0 0-8.217m0 1.441a2.667 2.667 0 1 1 0 5.334 2.667 2.667 0 0 1 0-5.334"/>
</svg>
<a class="button is-primary" href="https://docs.google.com/forms/d/1xuxpRnFR-uMXdiX2p-1oTutfz6PXqIBbLNzJyI6tfqY/edit">
<strong>Register</strong>
</a>
<!-- <a class="button is-light" href="https://mbit-live.mbhs.edu/login">Login</a> -->
</div>
</div>
</div>

</div>
</nav>
<main class="wrapper">

<section class="hero has-background-primary">
<div class="hero-body">
<div class="container">
<h1 class="title is-1"><span class="has-text-white">Spring 2024</span></h1>
</div>
</section>
<section class="section">
<div class="container">
<div class="content"><p>The Spring 2024 round took place on June 8th, 2024. The contest was held both in-person and virtually with 25 teams and 80 competitors coming in-person and another 72 teams with 136 competitors competing online.</p></div>
<h2 class="subtitle is-4">Problems</h2>
<div class="content">
<p>Test solutions on our Codeforces Gyms: <a target="_blank" href="https://codeforces.com/group/stXErQM0NN/members">Problems</a>, <a target="_blank" href="https://docs.google.com/document/d/1084MSbNk0d6hDq9yxOLC4oQ-k5_b4G01_RbIcblRW_E/edit">Editorials</a>
</div>
<h2 class="subtitle is-4">In person</h2>
<h2 class="subtitle is-5">Advanced Division</h2>
<div class="content">
<p>1. <em>Obesity Epidemic</em> - Gabriel Xu, Avnith Vijayram, Max Wang, Samarth Bhargav (Thomas Jefferson High School for Science and Technology)
</div>
<h2 class="subtitle is-5">Standard Division</h2>
<div class="content">
<p class="mb-0"><strong>High School Winners</strong></p>
<p>1. <em>mont</em> - David Wang, Bill Qian, Daniel Li, Sam Easaw (Montgomery Blair High School)</p>
<p>2. <em>rhhsprogclub</em> - Nathan Zhong, Gavin Zhaom, Jonathan Cai, Alex Zhu (River Hill High School)</p>
<p>3. <em>The DP Demons</em> - Taha Rawjani, Matthew Li, Arush Bodla, Rohit Rajakumar (Academies of Loudoun)</p>
<p class="mb-0"><strong>Middle School Winners</strong></p>
<p>1. <em>cookies</em> - Liam Bryce, Ethan Qin, Ari Bernstein, Asher Bleimund (Takoma Park Middle School)</p>
<p>2. <em>Pi Game</em> - Gabriel Phillips, Fox Martone (Takoma Park Middle School)</p>
<p>3. <em>Vitruvian Lung</em> - Alex Wang (Takoma Park Middle School), Ruixi Zhang (Takoma Park Middle School), Daniel Hollis (Takoma Park Middle School), Angela Cheng (Robert Frost Middle School)</p>
<p class="mb-0"><strong>High School Winners</strong></p>
<p>1. <em>mont</em> - David Wang, Bill Qian, Daniel Li, Sam Easaw (Montgomery Blair High School)</p>
<p>2. <em>rhhsprogclub</em> - Nathan Zhong, Gavin Zhaom, Jonathan Cai, Alex Zhu (River Hill High School)</p>
<p>3. <em>The DP Demons</em> - Taha Rawjani, Matthew Li, Arush Bodla, Rohit Rajakumar (Academies of Loudoun)</p>
</div>
<h2 class="subtitle is-4">Online</h2>
<h2 class="subtitle is-5">Advanced Division</h2>
<div class="content">
<p>1. <em>ᴉoᴉ uᴉʍ llᴉʍ ǝxuq</em> - Bing-Dong Liu (Irvington High School), Thomas Liu (The Harker School), Brian Xue (Lynbrook High School), Alex Chen (Monta Vista High School)</p>
<p>2. <em>Heavy Light Decomposition</em> - Ryan Bai (Canyon Crest Academy), Bálint Rózsa (Bloor C.I.), Daniel Ye (William Lyon Mackenzie C.I.), Maxwell He (Shanghai High School International Division)</p>
<p>3. <em>Baby Bottom and Cooked Shrimp</em> - Rain Jiang (Homeschool), Kai Jiang (Homeschool)</p>
<p>4. <em>2027 EGOI Team</em> - Julian Wu (Westview High School), Jonathan He (Adlai E. Stevenson High School), Weiming Zhou (Massachussetts Institute of Technology), Tina Wang (Massachussetts Institute of Technology)</p>
<p>5. <em>liympanda</em> - Yiming Li (Google)</p>
</div>
</div>
</section>

</main>
<footer class="footer">
<div class="content has-text-centered">
<p>Organized by students at <a href="https://mbhs.edu">Montgomery Blair High School</a>.</p>
</div>
</footer>
<script src="/ui.js"></script>
</body>
</html>
69 changes: 69 additions & 0 deletions archive/2024s/solutions/BehindTheScenes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// int max = 2 147 483 647 (2^31-1)
// ll max = 9 223 372 036 854 775 807 (2^63-1)
#include <bits/stdc++.h>
using namespace std;

#define forn(i, n) for (int i = 0; i < n; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pi;

// Fast input and output
void fast_io() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}

// Printing pairs and vectors
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
cout << "[";
forn(i, (int)v.size()) {
if (i) cout << ", ";
cout << v[i];
}
return cout << "]";
}

mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// use uniform_int_distribution<int>(a, b)(rng) if you want [a, b].

int main() {
fast_io();
int n;
cin >> n;
vector<pi> s(n);
forn(i, n) cin >> s[i].f;
forn(i, n) s[i].s = i;
sort(s.begin(), s.end());
string pans;
vector<string> ans(n);
forn(i, n) {
if (i == 0 or s[i].f != s[i - 1].f) {
pans = "";
forn(j, s[i].f) pans.pb('a');
} else {
for (int j = s[i].f - 1; j >= 0; j--) {
if (pans.at(j) != 'z') {
pans.at(j)++;
break;
}
pans.at(j) = 'a';
}
}
ans[s[i].s] = pans;
}
forn(i, n) cout << ans[i] << "\n";
}
// code by DanTheMan
22 changes: 22 additions & 0 deletions archive/2024s/solutions/BehindTheScenes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# faster io
from sys import stdin, stdout

n = int(stdin.readline())
l = stdin.readline().split()
# nextbest[i] represents the lexicographic least unused string of length i
# must use nested lists because strings are immutable
nextbest = [[]] * 5001
for i in range(1, 5001):
nextbest[i] = ["a"] * i # they all start as all a's
for i in range(n):
length = int(l[i])
for i in range(length): # output string represented by nextbest[length]
stdout.write(nextbest[length][i])
stdout.write(" ")
# update nextbest[length] to the next lexicographic string
for j in range(length - 1, -1, -1):
if nextbest[length][j] == "z": # set all trailing 'z's to be 'a'
nextbest[length][j] = "a"
else: # increment the first non-z letter from back
nextbest[length][j] = chr(ord(nextbest[length][j]) + 1)
break
131 changes: 131 additions & 0 deletions archive/2024s/solutions/Boardwalk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
Equalize Array
difference array on circular array
mcmf
*/

#include "bits/stdc++.h"
using namespace std;

#define rep(i, a, b) for (int i = a; i <= b; i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define f first
#define s second
#define nl "\n"
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

// copied from ?
// works for negative edges
template <class C, class F>
struct MCMF {
static constexpr F eps = (F)1e-9;
struct Edge {
int v, inv;
F cap, flow;
C cost;
Edge(int v, C cost, F cap, int inv) : v(v), cost(cost), cap(cap), flow(0), inv(inv) {}
};

int s, t, n, m = 0;
vector<vector<Edge> > g;
vector<C> cost;
vi state, path, from;

MCMF(int n, int ss = -1, int tt = -1) : n(n), g(n + 5), cost(n + 5), state(n + 5), path(n + 5), from(n + 5) {
s = ss == -1 ? n + 1 : ss;
t = tt == -1 ? n + 2 : tt;
}

void add(int u, int v, F cap, C cost) {
g[u].pb(Edge(v, cost, cap, sz(g[v])));
g[v].pb(Edge(u, -cost, 0, sz(g[u]) - 1));
m += 2;
}

bool bfs() {
fill(all(state), 2);
fill(all(cost), numeric_limits<C>::max());
deque<int> qu;
qu.push_back(s);
state[s] = 1, cost[s] = 0;
while (sz(qu)) {
int u = qu.front();
qu.pop_front();
state[u] = 0;
for (Edge &e : g[u])
if (e.cap - e.flow > eps)
if (cost[u] + e.cost < cost[e.v]) {
cost[e.v] = cost[u] + e.cost;
path[e.v] = u;
from[e.v] = g[e.v][e.inv].inv;
if (state[e.v] == 0 || (sz(qu) && cost[qu.front()] > cost[e.v]))
qu.push_front(e.v);
else if (state[e.v] == 2)
qu.push_back(e.v);
state[e.v] = 1;
}
}
return cost[t] != numeric_limits<C>::max();
}

pair<C, F> minCostFlow() {
C cost = 0;
F flow = 0;
while (bfs()) {
F nflow = numeric_limits<F>::max();
for (int u, v = t; v != s; v = u) {
u = path[v];
Edge &e = g[u][from[v]];
nflow = min(nflow, e.cap - e.flow);
}
for (int u, v = t; v != s; v = u) {
u = path[v];
g[u][from[v]].flow += nflow;
g[v][g[u][from[v]].inv].flow -= nflow;
cost += g[u][from[v]].cost * nflow;
}
flow += nflow;
}
return make_pair(cost, flow);
}
};

const int N = 201;
int n, k;
int a[N], d[N];

int main() {
cin.tie(0)->sync_with_stdio(0);

cin >> n >> k;
MCMF<ll, ll> mf(n + 2, 0, n + 1);
rep(i, 1, n) cin >> a[i];
a[0] = a[n];
ll sumd = 0;
rep(i, 1, n) {
d[i] = a[i] - a[i - 1];
}
int maxC = 0;
rep(i, 1, k) {
int l, r, c;
cin >> l >> r >> c;
maxC = max(maxC, c);
mf.add(l, (r == n ? 1 : r + 1), 1e18, c);
}
ll need = 0;
rep(i, 1, n) {
if (d[i] < 0) mf.add(0, i, -d[i], 0);
if (d[i] > 0) mf.add(i, n + 1, d[i], 0), need += d[i], sumd += d[i];
}
auto p = mf.minCostFlow();
assert(p.f <= sumd * n * maxC);
if (p.s != need)
cout << -1;
else
cout << p.f;
}
Loading

0 comments on commit 80e5d3f

Please sign in to comment.