Datasets:
cpid int64 1.54k 1.6k | title stringlengths 6 31 | contest stringclasses 4
values | division stringclasses 5
values | problem_number int64 1 3 | source_url stringlengths 55 55 | statement_md stringlengths 1.44k 4.17k | checker_kind stringclasses 3
values | time_limit_s float64 2 6 | memory_limit_mb int64 256 512 | n_tests int64 10 20 | n_sample_tests int64 1 3 | point_scores listlengths 10 20 | val_cpp stringlengths 295 1.44k | std_cpp stringlengths 337 3.04k | chk_cpp stringclasses 6
values | std_source_submission_id int64 70.9k 169k | std_origin stringlengths 50 58 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,539 | Chip Exchange | First Contest | Bronze | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1539 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Bessie the cow has in her possession $A$ chips of type A and $B$ chips of type B ($0\le A, B\le 10^9$). She can perform the following operation as many times as she likes:
> If you have at least $c_B$ chips of type B, exchange $c_B$ chips of... | UOJ builtin: ncmp | 2 | 256 | 10 | 2 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 10000, "T");
inf.readEoln();
for (int tc = 1; tc <= T; tc++) {
inf.readInt(0, 1000000000, "A"); inf.readSpace();
inf.readInt(0, 1000000000, "B"); inf.readSpace();
inf.re... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve(ll A, ll B, ll cA, ll cB, ll fA) {
ll init = B / cB * cA + A;
if (init >= fA) return 0;
ll nA0 = fA - 1 - init;
ll y = cB - 1 - B % cB;
if (cA >= cB) y += nA0;
else y += nA0 / cA * cB + nA0 % cA;
return y + 1;
}
i... | null | 70,933 | hand C++ translation (earliest root AC #70933 was Python3) |
1,540 | COW Splits | First Contest | Bronze | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1540 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Bessie is given a positive integer $N$ and a string $S$ of length $3N$ which is generated by concatenating $N$ strings of length $3$, each of which is a cyclic shift of "COW". In other words, each string will be "COW", "OWC", or "WCO".
Strin... | custom (chk.cpp, testlib) | 2 | 256 | 12 | 2 | [
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
12
] | #include "testlib.h"
#include <string>
static bool isCyclicCOW(const std::string& g) {
return g == "COW" || g == "OWC" || g == "WCO";
}
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 10000, "T");
inf.readSpace();
inf.readInt(0, 1, "k");
inf.readEoln();
... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t, x; cin >> t >> x;
while (t--) {
int n; cin >> n;
string s; cin >> s;
if (n & 1) {
cout << -1 << endl;
continue;
}
vector<int> ans(n * 3, 1);
for (int i = 0; i < n / 2; i++) {
... | #include "testlib.h"
#include <vector>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
setName("USACO 2026 Bronze: COW Splits");
registerTestlibCmd(argc, argv);
int T = inf.readInt();
int K = inf.readInt();
for (int t = 1; t <= T; t++) {
int N = inf.readInt();
... | 70,934 | verbatim earliest root score=100 submission #70934 |
1,541 | Photoshoot | First Contest | Bronze | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1541 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Farmer John is looking at his cows in a magical field and wants to take pictures of subsets of his cows.
The field can be seen as a $N\times N$ grid ($1\le N\le 500$), with a single stationary cow at each location. Farmer John's camera is ca... | UOJ builtin: ncmp | 2 | 256 | 16 | 2 | [
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
10
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(1, 500, "N");
inf.readSpace();
int K = inf.readInt(1, std::min(N, 25), "K");
inf.readEoln();
int Q = inf.readInt(1, 30000, "Q");
inf.readEoln();
for (int i = 1; i <= Q; i++) {
... | #include <algorithm>
#include <ios>
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int k;
int n;
int q;
cin >> n >> k >> q;
int mx_sum = 0;
vector sums(n, vector<int>(n));
vector vals(n, vector<int>(n));
for (int i = 0; i < q; ++i) {
int c;
... | null | 70,935 | verbatim earliest root score=100 submission #70935 |
1,542 | Lineup Queries | First Contest | Silver | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1542 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
There is a line of cows, initially (i.e. at time $t = 0$) containing only cow $0$ at position $0$ (here, a cow is at position $k$ if there are $k$ cows in front of it). At time $t$ for $t = 1, 2, 3, \dots$, the cow at position $0$ moves to po... | UOJ builtin: ncmp | 2 | 256 | 10 | 2 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
const long long MAXT = 1000000000000000000LL;
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int Q = inf.readInt(1, 100000, "Q");
inf.readEoln();
for (int q = 1; q <= Q; q++) {
int type = inf.readInt(1, 2, "type");
inf.readSpace();
long lo... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// which cow is at position, given time (iterative to avoid deep recursion)
ll get_pos(ll i, ll t) {
if (t < 2 * i) return i;
ll cur_t = 2 * i - 1;
t -= cur_t;
ll pos = i;
while (t >= 0) {
if (t <= pos) return pos - t;
... | null | 70,930 | hand C++ translation (earliest root AC #70930 was Python3) |
1,543 | Mooclear Reactor | First Contest | Silver | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1543 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Bessie is designing a nuclear reactor to power Farmer John's lucrative new AI data center business, CowWeave!
The reactor core consists of $N$ ($1\le N\le 2\cdot 10^5$) fuel rods, numbered $1$ through $N$. The $i$-th rod has a "stable operat... | UOJ builtin: ncmp | 2 | 256 | 10 | 3 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
#include <vector>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 400000, "T");
inf.readEoln();
long long sumN = 0, sumM = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 400000, "N");
inf.readSpace();
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve() {
int n, m;
cin >> n >> m;
vector<int> l(n), r(n);
for (int &i : l) cin >> i;
for (int &i : r) cin >> i;
vector<vector<pair<int, int>>> adj(n);
while (m--) {
int i, j, x;
cin >> i >> j >>... | null | 70,931 | verbatim earliest root score=100 submission #70931 |
1,544 | Sliding Window Summation | First Contest | Silver | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1544 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Bessie has a hidden binary string $b_1 b_2\dots b_N$ ($1\le N\le 2\cdot 10^5$).
The only information about $b$ you are given is a binary string $r_1 r_2\dots r_{N-K+1}$ ($1\le K\le N$), where $r_i$ is the remainder when the number of ones in... | UOJ builtin: ncmp | 2 | 256 | 10 | 1 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
#include <string>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 1000, "T");
inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 1000000, "N");
inf.readSpace();
int K = in... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int T;
scanf("%d", &T);
while (T--) {
int N, K;
scanf("%d %d", &N, &K);
static char buf[1000006];
scanf("%s", buf);
string r(buf);
ll min_sum = 0;
int parity = 0;
... | null | 70,932 | hand C++ translation (earliest root AC #70932 was Python3) |
1,545 | COW Traversals | First Contest | Gold | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1545 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
There are $N$ ($1\le N\le 2\cdot 10^5$) cows labeled $1\dots N$ on Farmer John's farm, where each cow lives in its own barn. Each cow $i$ has a best friend $a_i$ ($1\le a_i\le N$). Cows can be best friends with themselves, and multiple cows c... | UOJ builtin: ncmp | 2 | 256 | 20 | 1 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(1, 200000, "N");
inf.readEoln();
for (int i = 1; i <= N; i++) {
inf.readInt(1, N, "a_i");
if (i < N) inf.readSpace();
}
inf.readEoln();
int M = inf.readInt(1, 20000... | #include <bits/stdc++.h>
using namespace std;
vector<int> rt; // roots of each tree
struct dsu : vector<int> {
dsu(int n) : vector(n, -1) {}
int rep(int x) { return at(x) < 0 ? x : at(x) = rep(at(x)); }
int sz(int x) { return -at(rep(x)); }
bool same(int x, int y) { return rep(x) == rep(y); }
bool ... | null | 70,927 | verbatim earliest root score=100 submission #70927 |
1,546 | Milk Buckets | First Contest | Gold | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1546 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Bessie has challenged Farmer John to a game involving milk buckets! There are $N$ ($2 \le N \le 2\cdot 10^5$) milk buckets lined up in a row. The $i$-th bucket from the left initially contains $a_i$ ($0 \le a_i \le 10^9$) gallons of milk.
Th... | UOJ builtin: ncmp | 2 | 256 | 12 | 2 | [
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
12
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 100, "T");
inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int n = inf.readInt(2, 200000, "N");
inf.readEoln();
sumN += n;
for (int ... | #include <bits/stdc++.h>
using namespace std;
struct BIT {
int n;
vector<int> t;
BIT(int _n) : n(_n), t(n + 1) {}
void add(int k, int x) {
while(k <= n) {
t[k] += x;
k += k&-k;
}
}
int sum(int r) {
int sm = 0;
while(r > 0) {
... | null | 70,928 | verbatim earliest root score=100 submission #70928 |
1,547 | Supervision | First Contest | Gold | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1547 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
There are $N$ ($1\le N\le 10^6$) cows in cow camp, labeled $1\dots N$. Each cow is either a camper or a coach.
A nonempty subset of the cows will be selected to attend a field trip. If the $i$-th cow is selected, the cow will move to positio... | UOJ builtin: ncmp | 2 | 256 | 14 | 2 | [
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
9
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(1, 1000000, "N");
inf.readSpace();
inf.readInt(0, 1000000000, "D");
inf.readEoln();
long long prev = -1;
for (int i = 1; i <= N; i++) {
int p = inf.readInt(0, 1000000000, "p_i"... | #include <bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, b, a) for(int i = (b); i >= (a); i--)
using namespace std;
const int N = 1e6 + 5, MOD = 1e9 + 7;
ll p, D, inv2 = (MOD + 1) / 2, qp[N], qg[N];
int main() {
int n; scanf("%d%lld", &n, &D);
ll mul = 1,... | null | 70,929 | verbatim earliest root score=100 submission #70929 |
1,548 | Hoof, Paper, Scissors Triples | First Contest | Platinum | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1548 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
You have probably heard of the game "Rock, Paper, Scissors". The cows like to play a similar game they call "Hoof, Paper, Scissors".
The rules of "Hoof, Paper, Scissors" are simple. Two cows play against each other. They both count to three ... | UOJ builtin: ncmp | 2 | 256 | 20 | 1 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 50000, "T");
inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int n = inf.readInt(3, 200000, "N");
inf.readEoln();
sumN += n;
for (in... | #include <bits/stdc++.h>
using namespace std;
struct Point {
long long x, y;
};
long long cross(Point a, Point b) {
return a.x * b.y - a.y * b.x;
}
int half(Point p) {
return p.y > 0 || (p.y == 0 && p.x > 0) ? 1 : -1;
}
bool angleCmp(Point a, Point b) {
int h1 = half(a), h2 = half(b);
return h1 == h... | null | 70,924 | verbatim earliest root score=100 submission #70924 |
1,549 | Lineup Counting Queries | First Contest | Platinum | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1549 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
There is a line of cows, initially (i.e. at time $t = 0$) containing only cow $0$ at position $0$ (here, a cow is at position $k$ if there are $k$ cows in front of it). At time $t$ for $t = 1, 2, 3, \dots$, the cow at position $0$ moves to po... | UOJ builtin: ncmp | 2 | 256 | 19 | 2 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
10
] | #include "testlib.h"
const long long MAXT = 1000000000000000000LL; // 1e18
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int Q = inf.readInt(1, 100000, "Q");
inf.readEoln();
for (int q = 1; q <= Q; q++) {
long long l1 = inf.readLong(0, MAXT, "l1");
inf.readSpace(... | #include <bits/stdc++.h>
using namespace std;
vector<long long> inv(long long n){
vector<long long> ans;
ans.push_back(4000000000000000000);
for(int i=0;i<111;i++){
ans.push_back(n);
n = (2*n+4)/3-2;
}
return ans;
}
int main(){
int q;
cin >> q;
while(q--){
long ... | null | 70,925 | verbatim earliest root score=100 submission #70925 |
1,550 | Pluses and Minuses | First Contest | Platinum | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1550 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Farmer John once painted a rectangular grid on the ground of his pasture. In each cell, he painted either a $+$ or a $-$ (representing $+1$ and $-1$, respectively).
Over time, the paint faded, and Farmer John now remembers the values of only... | UOJ builtin: ncmp | 2 | 256 | 20 | 2 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
#include <set>
#include <utility>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 100, "T");
inf.readEoln();
long long sumR = 0, sumC = 0, sumX = 0;
for (int tc = 1; tc <= T; tc++) {
int R = inf.readInt(1, 500000, "R");
... | #include <bits/stdc++.h>
using i64 = long long;
struct Cell {
int v, r, c;
};
void tc() {
int r, c, x;
std::cin >> r >> c >> x;
std::vector<Cell> cl(x);
for (auto& [v, ri, ci] : cl) {
char cc;
std::cin >> cc >> ri >> ci;
v = cc == '+';
--ri;
--ci;
}
if (r == 1 && c == 1) {
if ... | null | 70,926 | verbatim earliest root score=100 submission #70926 |
1,563 | It's Mooin' Time IV | Second Contest | Bronze | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1563 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Bessie has a computer with a keyboard that only has two letters, `M` and `O`.
Bessie wants to type her favorite moo $S$ consisting of $N$ letters, each of which is either an `M` or an `O`. However, her computer has been hit with a virus. Eve... | custom (chk.cpp, testlib) | 2 | 256 | 14 | 2 | [
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
9
] | #include "testlib.h"
#include <string>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 10000, "T"); inf.readSpace();
inf.readInt(0, 1, "k"); inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 200000, "N"); in... | #include <iostream>
using namespace std;
int main() {
int t, mode;
cin >> t >> mode;
while(t--) {
int n;
string s;
cin >> n >> s;
cout << "YES\n";
if(mode == 0) continue;
for(int i = 0; i+1 < n; i++) {
if(s[i] == s[i+1]) cout << 'M';
else cout << 'O';
}
cout << s.back... | #include "testlib.h"
#include <string>
using namespace std;
static string simulate(const string &keys) {
int n = keys.size();
string s(n, '?');
int suffO = 0; // number of 'O' strictly after position i, computed right-to-left
for (int i = n - 1; i >= 0; --i) {
char base = keys[i];
// 'O... | 70,970 | verbatim earliest root score=100 submission #70970 |
1,564 | Moo Hunt | Second Contest | Bronze | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1564 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Bessie is playing the popular game "Moo Hunt". In this game, there are $N$ ($3\le N\le 20$) cells in a line, numbered from $1$ to $N$. All cells either have the character $M$ or $O$ with the $i$-th cell having character $s_i$.
Bessie plans t... | UOJ builtin: ncmp | 2 | 256 | 10 | 2 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(3, 20, "N"); inf.readSpace();
int K = inf.readInt(1, 200000, "K"); inf.readEoln();
for (int i = 1; i <= K; i++) {
int x = inf.readInt(1, N, "x"); inf.readSpace();
int y = inf.readI... | #include <bits/stdc++.h>
using namespace std;
int main(){
int n, k;
cin >> n >> k;
vector<vector<vector<int>>> isAt(n, vector<vector<int>>(n, vector<int>(n, 0)));
for (int i = 0; i < k; i++) {
int x, y, z;
cin >> x >> y >> z;
x--; y--; z--;
isAt[x][y][z]++;
}
... | null | 70,946 | verbatim earliest root score=100 submission #70946 |
1,565 | Purchasing Milk | Second Contest | Bronze | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1565 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
On National Milk Day, Farmer John is offering exclusive prices on buckets of milk! He has $N$ ($1\le N\le 10^5$) deals numbered from $1$ to $N$. For the $i$-th deal, he is offering $2^{i-1}$ buckets of milk for $a_i$ ($1\le a_i\le 10^9$, $a_i... | UOJ builtin: ncmp | 2 | 256 | 14 | 2 | [
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
9
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(1, 100000, "N"); inf.readSpace();
int Q = inf.readInt(1, 10000, "Q"); inf.readEoln();
long long prev = 0;
for (int i = 1; i <= N; i++) {
int a = inf.readInt(1, 1000000000, "a_i");
... | #include <stdio.h>
#include <stdint.h>
#include <limits.h>
#include <algorithm>
using namespace std;
void solve()
{
int N, K, Q;
scanf("%d %d", &N, &Q);
int price[N];
scanf("%d", &price[0]);
for (int idx = 1; idx < N; ++idx)
{
scanf("%d", &price[idx]);
price[idx] = min(price[i... | null | 70,947 | verbatim earliest root score=100 submission #70947 |
1,566 | Cow-libi 2 | Second Contest | Silver | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1566 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Farmer John and Farmer Nhoj have taken their respective cows to sit around a campfire in hopes of settling their personal differences. In total, there are $N$ ($2\le N\le 10^5$) cows sitting in a circular formation. When the farmers are ready... | custom (chk.cpp, testlib) | 2 | 256 | 10 | 2 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
#include <string>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 1000, "T"); inf.readSpace();
inf.readInt(0, 1, "C"); inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(2, 100000, "N"); inf... | #include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define nl '\n'
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t, c; cin >> t >> c;
while (t--) {
int n; c... | #include "testlib.h"
#include <string>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
setName("USACO 2026 Silver: Cow-libi 2");
registerTestlibCmd(argc, argv);
int T = inf.readInt();
int C = inf.readInt();
for (int t = 1; t <= T; t++) {
int N = inf.readInt();
... | 70,971 | verbatim earliest root score=100 submission #70971 |
1,567 | Declining Invitations | Second Contest | Silver | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1567 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
$N$ contestants participated in a contest, each placing a distinct rank from $1$ to $N$. There are $C$ criteria used to invite contestants to participate in the final round, and the $i$-th-ranked contestant satisfies a specified $n_i$ of them... | UOJ builtin: ncmp | 2 | 256 | 13 | 3 | [
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
16
] | #include "testlib.h"
#include <set>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(1, 100000, "N"); inf.readSpace();
int C = inf.readInt(1, 100000, "C"); inf.readEoln();
for (int i = 1; i <= C; i++) { inf.readInt(1, N, "f_i"); if (i < C) inf.readSpace(); }
inf... | #include <bits/stdc++.h>
using namespace std;
template <class T> using V = vector<T>;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, C;
cin >> N >> C;
V<int> f(C);
for (int &t : f) cin >> t;
V<int> p(N);
for (int &t : p) {
cin >> t;
--t; // zero-in... | null | 70,943 | verbatim earliest root score=100 submission #70943 |
1,568 | Farmer John Loves Rotations | Second Contest | Silver | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1568 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Farmer John has an array $A$ containing $N$ integers ($1\le N\le 5\cdot 10^5$, $1\le A_i\le N$). He picks his favorite index $j$ and takes out a sheet of paper with only $A_j$ written on it. He can then perform the following operation some nu... | UOJ builtin: ncmp | 2 | 256 | 15 | 2 | [
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
16
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(1, 500000, "N"); inf.readEoln();
for (int i = 1; i <= N; i++) { inf.readInt(1, N, "A_i"); if (i < N) inf.readSpace(); }
inf.readEoln();
inf.readEof();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
template <class T> using V = vector<T>;
#define all(x) begin(x), end(x)
void ckmin(int &a, int b) { a = min(a, b); }
void ckmax(int &a, int b) { a = max(a, b); }
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
V<int> A(N)... | null | 70,944 | verbatim earliest root score=100 submission #70944 |
1,569 | Balancing the Barns | Second Contest | Gold | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1569 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Farmer John has $N$ ($1\le N\le 5\cdot 10^4$) barns arranged along a road. The $i$-th barn contains $a_i$ bales of hay and $b_i$ bags of feed ($0\le a_i, b_i\le 10^9$).
Bessie has been complaining about the inequality between barns. She defi... | UOJ builtin: ncmp | 2 | 256 | 12 | 1 | [
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
12
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 1000, "T"); inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 50000, "N"); inf.readSpace();
inf.readLong(1, 1000000000000000000LL, "K"... | #include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n;
int64_t k;
cin >> n >> k;
vector<int64_t> a(n), b(n);
for(auto& x: a) cin >> x;
for(auto& x: b) cin >> x;
auto can = [&](int64_t thresh) -> bool {
vector<int64_t>... | null | 70,939 | verbatim earliest root score=100 submission #70939 |
1,570 | Lexicographically Smallest Path | Second Contest | Gold | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1570 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Bessie is given an undirected graph with $N$ ($1\le N\le 2\cdot 10^5$) vertices labeled $1\dots N$ and $M$ edges ($N - 1\le M\le 2\cdot 10^5$). Each edge is described by two integers $u, v$ ($1\le u, v\le N$) describing an undirected edge bet... | UOJ builtin: ncmp | 2 | 256 | 20 | 2 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 10, "T"); inf.readEoln();
long long sumN = 0, sumM = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 400000, "N"); inf.readSpace();
int M = inf.readInt(std::max(0, N... | #include "bits/stdc++.h"
#define endl '\n'
#define f first
#define s second
using namespace std;
const int N = 2e5 + 5, A = 28;
int n, m;
vector<pair<int, int>> g[N];
int ans[N];
void ac() {
cin >> n >> m;
for (int i = 1; i <= n; i++) ans[i] = -1, g[i].clear();
for (int i = 1; i <= m; i++) {
int... | null | 70,940 | verbatim earliest root score=100 submission #70940 |
1,571 | The Chase | Second Contest | Gold | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1571 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Bessie is trying to evade the farmers. The farmers own $N$ ($2\le N\le 5\cdot 10^5$) farms with a one-way road between the $i$-th farm and the $a_i$-th farm ($1\le i\le N$, $a_i\ne i$). There are $F$ ($1\le F\le N$) farmers and the $i$-th far... | UOJ builtin: ncmp | 2 | 256 | 20 | 1 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
#include <set>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(2, 500000, "N"); inf.readSpace();
int F = inf.readInt(1, N, "F"); inf.readEoln();
for (int i = 1; i <= N; i++) {
inf.readInt(1, N, "a_i");
if (i < N) inf.readSpace()... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, f;
cin >> n >> f;
vector<int> nxt(n + 1), hasFarmer(n + 1, 0);
vector<vector<int>> radj(n + 1);
for (int i = 1; i <= n; i++) {
cin >> nxt[i];
radj[nxt[i]].push_back(i... | null | 70,941 | verbatim earliest root score=100 submission #70941 |
1,572 | Circle of Cows | Second Contest | Platinum | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1572 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Farmer John has $N$ ($2\le N\le 1000$) cows at distinct locations $l_1, \dots, l_N$ along a circle of circumference $C$ ($0\le l_1 < l_2 < \dots < l_N < C$, $N\le C\le 10^9$).
FJ will select $k$ pairs of cows, where $1\le k\le \lfloor N/2\rf... | UOJ builtin: ncmp | 2 | 256 | 20 | 2 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(2, 1000, "N");
inf.readSpace();
int C = inf.readInt(N, 1000000000, "C");
inf.readEoln();
long long prev = -1;
for (int i = 1; i <= N; i++) {
int l = inf.readInt(0, C - 1, "l_i"... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N, C;
cin >> N >> C;
vector<int> L(N);
for (auto & x: L) {
cin >> x;
}
vector<int> ans(N / 2 + 1);
for (int i = 0; i < N; ++i) {
for (int j = i + ... | null | 70,936 | verbatim earliest root score=100 submission #70936 |
1,573 | Cow Circle | Second Contest | Platinum | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1573 | **Time limit:** 6 seconds **Memory limit:** 512 megabytes
> **Note:** The time limit for this problem is 6s, thrice the default. The memory limit for this problem is 512 MB, twice the default.
## Description
Farmer John has $N$ ($1\le N\le 5000$) cows standing around a circular track divided into $M$ ($1\le M\le ... | UOJ builtin: ncmp | 6 | 512 | 14 | 1 | [
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
9
] | #include "testlib.h"
const long long MOD = 1000000007LL;
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 100, "T");
inf.readEoln();
long long sumN2 = 0, sumM = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 5000, "N"); inf.readSpace();
... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
int bpow(int x, int y) {
return (y == 0) ? 1 : ((ll)bpow((ll)x * x % MOD, y / 2) * ((y % 2) ? x : 1) % MOD);
}
void mulp(vector<int>& poly, int pr) {
int npr = (MOD + 1 - pr) % MOD;
if(npr == 0) return;
poly... | null | 70,937 | verbatim earliest root score=100 submission #70937 |
1,574 | Dynamic Instability | Second Contest | Platinum | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1574 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Farmer Nhoj has trapped Bessie on a rooted tree with $N$ ($2\le N\le 2\cdot 10^5$) nodes, where node $1$ is the root. Scared and alone, Bessie makes the following move each second:
- If Bessie's current node has no children, then she will mo... | UOJ builtin: ncmp | 2 | 256 | 20 | 3 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(2, 200000, "N"); inf.readSpace();
int Q = inf.readInt(1, 200000, "Q"); inf.readEoln();
for (int i = 2; i <= N; i++) {
inf.readInt(1, i - 1, "p_i"); // 1 <= p_i < i
if (i < N) inf... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mxn = 2e5+5;
const ll M = 1e9+7;
ll modpow(ll x, ll p) {
ll a = 1;
while (p) {
if (p & 1) a = a * x % M;
x = x * x % M;
p /= 2;
}
return a;
}
ll inv(ll x) {
assert(x != 0);
return modpow(x, M-2... | null | 70,938 | verbatim earliest root score=100 submission #70938 |
1,587 | Make All Distinct | Third Contest | Bronze | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1587 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
You have an integer array $a_1\dots a_N$ with elements initially in the range $[1, N]$ ($1\le N\le 2\cdot 10^5$), as well as a nonzero integer $K$ ($-N\le K\le N$, $K\ne 0$).
You may perform the following operation as many times as you'd lik... | UOJ builtin: ncmp | 2 | 256 | 12 | 1 | [
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
8,
12
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 10, "T"); inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 200000, "N"); inf.readSpace();
int K = inf.readInt(-N, N, "K"); inf.readEo... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
for (int tc = 0; tc < T; ++tc) {
int N, K;
cin >> N >> K;
vector<int> cnt(N);
for (int i = 0; i < N; ++i) {
int x;
cin ... | null | 70,958 | verbatim earliest root score=100 submission #70958 |
1,588 | Strange Function | Third Contest | Bronze | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1588 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
For all positive integers $x$, the function $f(x)$ is defined as follows:
- If $x$ has any digits that aren't $0$ or $1$, for each digit of $x$, set it to $1$ if it is odd or $0$ otherwise, and return $x$.
- Otherwise, return $x - 1$.
Given... | UOJ builtin: ncmp | 2 | 256 | 10 | 2 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
#include <string>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 100000, "T"); inf.readEoln();
long long totDigits = 0;
for (int tc = 1; tc <= T; tc++) {
std::string x = inf.readToken();
int len = (int)x.size();
ensu... | #include "bits/extc++.h"
using namespace std;
using ll = long long;
#define sz(x) int(std::size(x))
constexpr ll mod = 1e9+7;
void solve(){
string s;
cin>>s;
ll moves=0;
int n=sz(s);
ll tpow[n]{}; // powers of 2
tpow[0]=1;
for(int i = 1; i<n; i++){
tpow[i]=(tpow[i-1]*2)%mod... | null | 70,959 | verbatim earliest root score=100 submission #70959 |
1,589 | Swap to Win | Third Contest | Bronze | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1589 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Farmer John has a favorite string $t$ with $M$ characters. He also has $N$ strings $s_1, s_2, \ldots, s_N$ each with $M$ characters ($1\le N, M\le 1000$).
FJ can perform the following two types of operations:
1. FJ chooses any string $s_x$ ... | custom (chk.cpp, testlib) | 2 | 256 | 11 | 1 | [
9,
9,
9,
9,
9,
9,
9,
9,
9,
9,
10
] | #include "testlib.h"
#include <string>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 10, "T"); inf.readEoln();
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 1000, "N"); inf.readSpace();
int M = inf.readInt(1, 1000, "M"); inf.readEoln();
... | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
string t;
cin >> t;
vector<string> s(n);
for (int i = 0; i < n; i++) cin >> s[i];
vector<vector<int>> has(n, vector<int>(26, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {... | #include "testlib.h"
#include <vector>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
setName("USACO 2026 Bronze: Swap to Win");
registerTestlibCmd(argc, argv);
int T = inf.readInt();
for (int t = 1; t <= T; t++) {
int N = inf.readInt();
int M = inf.readInt()... | 70,973 | verbatim earliest root score=100 submission #70973 |
1,590 | Clash! | Third Contest | Silver | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1590 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Farmer John is playing a famous and strategic card game with his dear cow Bessie. FJ has $N$ ($2\le N\le 2\cdot 10^5$) cards, conveniently numbered from $1$ to $N$. The $i$-th card costs $a_i$ ($1\le a_i\le 10^9$) moolixir if FJ wants to play... | UOJ builtin: ncmp | 2 | 256 | 10 | 1 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
#include <set>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(2, 200000, "N"); inf.readSpace();
int H = inf.readInt(1, N - 1, "H"); inf.readEoln();
for (int i = 1; i <= N; i++) { inf.readInt(1, 1000000000, "a_i"); if (i < N) inf.readSpace(); }... | #include <bits/stdc++.h>
using namespace std;
template <class T> using V = vector<T>;
#define all(x) begin(x), end(x)
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, H;
cin >> N >> H;
using P = pair<int, int>;
V<P> A(N);
for (auto &p : A) cin >> p... | null | 70,955 | verbatim earliest root score=100 submission #70955 |
1,591 | Milk Buckets | Third Contest | Silver | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1591 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
There are $N$ ($1\le N\le 2\cdot 10^5$) buckets in a stack where the $i$-th bucket from the top has capacity $a_i$ gallons ($1\le a_i\le 10^9$). A tap above the top bucket sends one gallon of milk per second into the first bucket per second. ... | UOJ builtin: ncmp | 2 | 256 | 20 | 3 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int N = inf.readInt(1, 200000, "N"); inf.readEoln();
for (int i = 1; i <= N; i++) { inf.readInt(1, 1000000000, "a_i"); if (i < N) inf.readSpace(); }
inf.readEoln();
int Q = inf.readInt(1, 300000, "Q"); inf.readEo... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int cdiv(int a, int b) { return (a + b - 1) / b; }
const ll mx = 1e18;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (auto &i : a) cin >> i;
// precomp
set<int> s;
auto upd = [&](int i) {
if (i != 0 && a[... | null | 70,956 | verbatim earliest root score=100 submission #70956 |
1,592 | Point Elimination | Third Contest | Silver | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1592 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
You have $N$ ($2\le N\le 10^5$, $N$ is even) points $(x_i, y_i)$ ($1\le x_i, y_i\le 10^6$) on an infinite 2D-coordinate plane.
You can perform the following two types of operations any number of times:
- Choose two points that are directly ... | UOJ builtin: wcmp | 2 | 256 | 10 | 1 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 5000, "T"); inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(2, 100000, "N"); inf.readEoln();
ensuref(N % 2 == 0, "test %d: N must be ev... | #include <bits/stdc++.h>
using namespace std;
#define int int64_t
using vi = vector<int>;
using pi = array<int, 2>;
#define all(x) x.begin(), x.end()
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define nl '\n'
void solve() {
int n; cin >> n;
vi x(n), y(n);
FOR(i, 0, n) cin >> x[i] >> y[i];
so... | null | 70,967 | verbatim earliest root score=100 submission #70967 |
1,593 | Good Cyclic Shifts | Third Contest | Gold | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1593 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
For a permutation $p_1, p_2, \dots, p_N$ of $1\dots N$ ($1\le N\le 2\cdot 10^5$), let $f(p) = \sum_{i=1}^N \frac{|p_i - i|}{2}$. A permutation is *good* if it can be turned into the identity permutation using at most $f(p)$ swaps of adjacent ... | UOJ builtin: ncmp | 2 | 256 | 10 | 1 | [
10,
10,
10,
10,
10,
10,
10,
10,
10,
10
] | #include "testlib.h"
#include <set>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 100000, "T"); inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 200000, "N"); inf.readEoln();
sumN += N;
std::s... | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> p(n);
for (auto &i : p)
cin >> i;
// solve
stack<int> s;
vector<int> nl(n, -1);
for (int j = 0; j < 2; j++) {
for (int i = 0; i < n; i++) {
while (s.size() && p[i] >= p[s.top()])
s.pop();
... | null | 70,951 | verbatim earliest root score=100 submission #70951 |
1,594 | Picking Flowers | Third Contest | Gold | 2 | https://usaco.org/index.php?page=viewproblem2&cpid=1594 | **Time limit:** 3 seconds **Memory limit:** 256 megabytes
> **Note:** The time limit for this problem is 3s, 1.5x the default.
## Description
Farmer John's farm structure can be represented as a connected undirected graph with $N$ vertices and $M$ unweighted edges ($2\le N\le 2\cdot 10^5$, $N - 1\le M\le 2\cdot 1... | UOJ builtin: wcmp | 3 | 256 | 20 | 3 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
#include <set>
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 100, "T"); inf.readEoln();
long long sumN = 0, sumM = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(2, 200000, "N"); inf.readSpace();
int M = inf.readI... | #include <bits/stdc++.h>
using namespace std;
#define int int64_t
using vi = vector<int>;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define nl '\n'
void solve() {
int n, m, k, l; cin >> n >> m >> k >> l;
vector<int> s(k); for (auto& i : s) cin >> i;
vector<int> ... | null | 70,986 | verbatim earliest root score=100 submission #70986 |
1,595 | Random Tree Generation | Third Contest | Gold | 3 | https://usaco.org/index.php?page=viewproblem2&cpid=1595 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
Suppose the function $\text{randint}(l, r)$ returns an integer independently and uniformly at random from the range $[l, r]$.
Bessie generates a random labeled tree on $N$ vertices ($2\le N\le 2\cdot 10^5$) using the following two-step proce... | UOJ builtin: ncmp | 2 | 256 | 20 | 1 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 10, "T"); inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(2, 200000, "N"); inf.readEoln();
sumN += N;
for (int i = 1; i < N; i+... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
int main() {
cin.tie(0)->sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<vector<int>> adj(n);
for (int i = 0; i < n - 1; i++) {
int u, v;
... | null | 70,953 | verbatim earliest root score=100 submission #70953 |
1,596 | All Pairs Shortest Paths | Third Contest | Platinum | 1 | https://usaco.org/index.php?page=viewproblem2&cpid=1596 | **Time limit:** 2 seconds **Memory limit:** 256 megabytes
## Description
You have a bunch of triangular regions that tessellate an infinite 2D plane. The tessellation is defined as follows (see the diagram for a better understanding):
- Recall that Euler's formula states that $e^{ix} = \cos(x) + i\sin(x)$ for rea... | UOJ builtin: ncmp | 2 | 256 | 20 | 1 | [
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | #include "testlib.h"
int main(int argc, char *argv[]) {
registerValidation(argc, argv);
int T = inf.readInt(1, 2000000000, "T"); inf.readEoln();
long long sumN = 0;
for (int tc = 1; tc <= T; tc++) {
int N = inf.readInt(1, 200000, "N"); inf.readEoln();
sumN += N;
for (int i = 1; i... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int n;
cin >> n;
vector<array<int, 3>> p(n);
for (auto &[x, y, z] : p)
cin >> x >> y >> z;
// compute sum of pairwise abs difference given map of counts
auto calc_dir = [&](map<int, int> &m) {
ll ret = 0;
int po... | null | 70,948 | verbatim earliest root score=100 submission #70948 |
USACO-Judge
A benchmark for judging competitive-programming solutions: given a problem and a candidate solution, decide Accept / Reject, and on Reject, produce a concrete input that breaks the code. Existing hacking benchmarks are built entirely from known-wrong candidates, so they only test the breaking half of verification. USACO-Judge is balanced 1:2 AC:non-AC, so it also tests whether a verifier correctly accepts solutions that are actually correct. Built from 39 official USACO 2026 problems and 900 real candidate submissions.
problems (39 rows)
One row per problem: cpid (USACO's official problem id — usaco.org/index.php?page=viewproblem2&cpid=<cpid>),
title, contest, division, problem_number, source_url, statement_md, checker_kind,
time_limit_s, memory_limit_mb, n_tests, n_sample_tests, point_scores, val_cpp
(validator), std_cpp (reference solution), chk_cpp (custom checker, null for problems that
use a standard comparator), std_source_submission_id, std_origin.
submissions (900 rows: 270 easy + 630 hard)
One row per submission: sid, cpid (links to problems), split (easy/hard), code,
verdict (AC/WA/TLE/MLE/RE), score (0-100). 300 are AC, 600 are not. The easy
split draws from the 18 Bronze/Silver problems, hard from the 21 Gold/Platinum/Open problems.
Non-AC candidates are stratified across five score bands (1-19, 20-39, 40-59, 60-79, 80-99), each a distinct plateau of suboptimal algorithms rather than a single bug pattern.
- Downloads last month
- 73
