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
+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();
}