Vibe code scripts to edit and add usaco solutions

This commit is contained in:
2026-08-25 00:45:15 +01:00
parent a79ff12290
commit 6fd6d70b04
26 changed files with 1156 additions and 6 deletions
+7
View File
@@ -0,0 +1,7 @@
3 8
AATCCCAT
GATTGCAA
GGTCGCAA
ACTCCCAG
ACTCGCAT
ACTTCCAT
+70
View File
@@ -0,0 +1,70 @@
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define NL '\n'
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int (n); cin >> n
#define takeII(n,m) int (n),(m); cin >> n >> m
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
int main() {
STDIN("cownomics.in");
STDOUT("cownomics.out");
takeII(n, m);
vector<set<char>> S(m, set<char>());
vector<set<char>> P(m, set<char>());
F(i, 0, n) {
F(j, 0, m) {
char k;
cin >> k;
S[j].insert(k);
}
}
F(i, 0, n) {
F(j, 0, m) {
char k;
cin >> k;
P[j].insert(k);
}
}
int res = 0;
F(j, 0, m) {
vector<char> intersect;
set_intersection(S[j].begin(), S[j].end(), P[j].begin(), P[j].end(), back_inserter(intersect));
if (intersect.size() == 0) {
res++;
}
}
cout << res;
}
+4
View File
@@ -0,0 +1,4 @@
3 4
4 1 2 3
4 1 3 2
4 2 1 3
+72
View File
@@ -0,0 +1,72 @@
#include <cstdio>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define NL '\n'
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int (n); cin >> n
#define takeII(n,m) int (n),(m); cin >> n >> m
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
int main() {
STDIN("gymnastics.in");
STDOUT("gymnastics.out");
takeII(k, n);
vector<vector<int>> orders(k, vector<int>(n));
vector<vector<int>> orders2(k, vector<int>(n));
F(i,0,k) {
F(j,0,n) {
takeI(u);
u--;
orders[i][j] = u;
orders2[i][u] = j;
}
}
set<pair<int, int>> pairs;
F(i,0,n-1) {
F(j, i+1, n) {
pairs.insert({orders[0][i], orders[0][j]});
}
}
F(i,1,k) {
for (auto it = pairs.begin(); it != pairs.end(); ) {
auto [l, r] = *it;
if (orders2[i][l] > orders2[i][r])
it = pairs.erase(it); // erase returns the next valid iterator
else
++it;
}
if (pairs.empty()) break; // nothing left to filter
}
cout << pairs.size();
}
+8
View File
@@ -0,0 +1,8 @@
7 10
7 3
5 5
9 7
3 1
7 7
5 3
9 1
+84
View File
@@ -0,0 +1,84 @@
#include <algorithm>
#include <climits>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define FASTIO cin.tie(0)->sync_with_stdio(0)
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
#define NL '\n'
#define CM ", "
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int (n); cin >> n
#define takeII(n,m) int (n),(m); cin >> n >> m
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
int main() {
STDIO("balancing");
takeII(n, k);
vector<pair<int, int>> coords(n);
F(i,0,n) {
int x, y;
cin >> x >> y;
coords[i] = {x,y};
}
// Sort by X to easily separate below a and above a
int M = INT_MAX;
F(i,0,n) {
int a = coords[i].first+1;
F(j,0,n) {
int b = coords[j].second+1;
int first, second, third, fourth;
first = second = third = fourth = 0;
F(k,0,n) {
// Separate X by a
if (coords[k].first < a) {
// Separate Y by b
if (coords[k].second < b) {
first++;
} else {
second++;
}
} else {
// Separate Y by b
if (coords[k].second < b) {
third++;
} else {
fourth++;
}
}
}
int maxxx = max(max(max(first, second), third), fourth);
M = REMIN(M, maxxx);
}
}
cout << M;
}
+49
View File
@@ -0,0 +1,49 @@
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define NL '\n'
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int (n); cin >> n
#define takeII(n,m) int (n),(m); cin >> n >> m
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
int main() {
STDIN("pails.in");
STDOUT("pails.out");
takeIII(x,y,m);
int currX = 0, res = 0;
while (currX <= m) {
int currY = y * ((m - currX) / y);
res = max(res, currX + currY);
currX += x;
}
cout << res;
}
+1
View File
@@ -0,0 +1 @@
17 25 77
+57
View File
@@ -0,0 +1,57 @@
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define NL '\n'
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int (n); cin >> n
#define takeII(n,m) int (n),(m); cin >> n >> m
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
int main() {
STDIN("sleepy.in");
STDOUT("sleepy.out");
takeI(n);
vector<int> order(n);
F(i,0,n) {
int ord;
cin >> ord;
order[i] = ord-1;
}
int startOfIncreasingSequence = 0;
FDE(i,n-1,1) {
if (order[i-1] >= order[i]) {
startOfIncreasingSequence = i;
break;
}
}
cout << startOfIncreasingSequence;
}
+3
View File
@@ -0,0 +1,3 @@
4
1 2 4 3
+73
View File
@@ -0,0 +1,73 @@
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define NL '\n'
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int (n); cin >> n
#define takeII(n,m) int (n),(m); cin >> n >> m
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
int main() {
STDIN("taming.in");
STDOUT("taming.out");
takeI(n);
vector<int> logs(n);
F(i,0,n) cin >> logs[i];
if (logs[0] > 0) {
cout << -1 << endl;
return 0;
}
logs[0] = 0;
int countdown = -1, min_breakouts = 0, max_breakouts = 0;
FDE(i,n-1,0) {
if (countdown >= 0 and logs[i] >= 0 and logs[i] != countdown) {
cout << -1 << endl;
return 0;
}
if (logs[i] >= 0) {
countdown = logs[i];
}
if (countdown <= 0) {
max_breakouts++;
}
if (countdown == 0) {
min_breakouts++;
}
countdown--;
}
cout << min_breakouts << ' ' << max_breakouts << endl;
}
+2
View File
@@ -0,0 +1,2 @@
4
-1 -1 -1 1
@@ -0,0 +1 @@
ABCCABDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ
@@ -0,0 +1,68 @@
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define NL '\n'
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int (n); cin >> n
#define takeII(n,m) int (n),(m); cin >> n >> m
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
#define whileZ takeI(T); while(T--)
// ----- VECTOR -----
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
int main() {
STDIN("circlecross.in");
STDOUT("circlecross.out");
vector<pair<int,int>> C(26, pair<int,int>(-1, -1) );
F(i,0,52) {
char ch;
cin >> ch;
size_t idx = ch - 'A';
if (C[idx].first == -1) {
C[idx].first = i;
} else {
C[idx].second = i;
}
}
int res = 0;
F(i,0,25) {
F(j,i+1,26) {
auto a = C[i];
auto b = C[j];
if (b.first < a.first or b.first > a.second) {
if ( b.second > a.first and b.second < a.second) res++;
} else {
if ( b.second < a.first or b.second > a.second) res++;
}
}
}
cout << res;
}