Vibe code scripts to edit and add usaco solutions
This commit is contained in:
@@ -0,0 +1 @@
|
||||
https://usaco.org/index.php?page=viewproblem2&cpid=1469
|
||||
@@ -0,0 +1,85 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
// ----- TYPES -----
|
||||
typedef long long ll;
|
||||
typedef pair<int,int> pii;
|
||||
typedef vector<int> vi;
|
||||
|
||||
// ----- 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 takeL(n) ll n; cin >> n
|
||||
#define takeS(s) string s; cin >> s
|
||||
#define takeV(v,n) vi v(n); for (auto &x : v) cin >> x
|
||||
#define takeVL(v,n) vector<ll> v(n); for (auto &x : v) cin >> x
|
||||
#define whileZ takeI(T); while(T--)
|
||||
//
|
||||
// ----- MAX MIN -----
|
||||
#define REMAX(a,b) (a)=max((a),(b))
|
||||
#define REMIN(a,b) (a)=min((a),(b))
|
||||
|
||||
// ----- PAIRS -----
|
||||
#define fi first
|
||||
#define se second
|
||||
|
||||
// ----- OUTPUT -----
|
||||
#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL
|
||||
|
||||
// ----- DEBUG -----
|
||||
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
|
||||
#define DBG2(a,b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl
|
||||
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
|
||||
#define printV(a) printA(a,0,SZ(a)-1)
|
||||
|
||||
// ----- STL DS
|
||||
#define ALL(c) (c).begin(),(c).end()
|
||||
#define SZ(c) ((int)(c).size())
|
||||
#define SORT(c) sort(ALL(c))
|
||||
#define RSORT(c) sort(ALL(c), greater<>())
|
||||
#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end())
|
||||
#define pb push_back
|
||||
|
||||
int main() {
|
||||
FASTIO;
|
||||
|
||||
takeI(n);
|
||||
takeV(a,n);
|
||||
takeV(b,n);
|
||||
|
||||
vi sol(n+1,0);
|
||||
|
||||
F(l,0,n) {
|
||||
F(r,l,n) {
|
||||
reverse(a.begin() + l, a.begin() + r + 1);
|
||||
|
||||
int correct = 0;
|
||||
F(i,0,n) {
|
||||
if (b[i] == a[i]) correct++;
|
||||
}
|
||||
sol[correct]++;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto i : sol) {
|
||||
cout << i << NL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
7 3
|
||||
10
|
||||
5
|
||||
1
|
||||
12
|
||||
9
|
||||
5
|
||||
14
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#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("diamond.in");
|
||||
STDOUT("diamond.out");
|
||||
|
||||
takeII(n,k);
|
||||
vector<int> s(n+1), b1(n), b2(n);
|
||||
s[n] = INT_MAX;
|
||||
F(i,0,n) cin >> s[i];
|
||||
sort(ALL(s));
|
||||
|
||||
int l = 0, big = 0;
|
||||
F(r,0,n) {
|
||||
while (s[r] - s[l] >= k+1) l++;
|
||||
REMAX(big, r-l+1);
|
||||
b1[r] = big;
|
||||
}
|
||||
|
||||
int r = n-1;
|
||||
big = 0;
|
||||
FD(l,n-1,-1) {
|
||||
while (s[r] - s[l] >= k+1) r--;
|
||||
REMAX(big, r-l+1);
|
||||
b2[l] = big;
|
||||
}
|
||||
|
||||
int sol = 0;
|
||||
F(i,1,n) {
|
||||
REMAX(sol, b1[i-1] + b2[i]);
|
||||
}
|
||||
|
||||
cout << sol;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#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() {
|
||||
takeI(n);
|
||||
|
||||
vector<int> weights(2*n);
|
||||
F(i,0,2*n) cin >> weights[i];
|
||||
sort(ALL(weights));
|
||||
|
||||
vector<int> distances(2*n-1);
|
||||
F(i,0,2*n-1) distances[i] = abs(weights[i] - weights[i+1]);
|
||||
|
||||
int res = 0;
|
||||
|
||||
F(i,0,n-1) {
|
||||
auto it = min_element(ALL(distances));
|
||||
size_t idx = distance(distances.begin(), it);
|
||||
|
||||
res += *it;
|
||||
|
||||
if (it == distances.begin()) {
|
||||
weights.erase(weights.begin() + idx, weights.begin() + idx + 2);
|
||||
distances.erase(it, it+2);
|
||||
} else if (it == distances.end() - 1) {
|
||||
weights.erase(weights.begin() + idx, weights.begin() + idx + 2);
|
||||
distances.erase(it-1, it+1);
|
||||
} else {
|
||||
weights.erase(weights.begin() + idx, weights.begin() + idx + 2);
|
||||
distances.erase(it, it+2);
|
||||
distances[idx-1] = abs(weights[idx-1] - weights[idx]);
|
||||
}
|
||||
// find i st distances[i] is minimal
|
||||
// remove distances[i], weights[i]
|
||||
// recompute distances[i-1], distances[i]
|
||||
}
|
||||
|
||||
cout << res;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#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 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() {
|
||||
FASTIO;
|
||||
|
||||
whileZ {
|
||||
takeI(n);
|
||||
vector<int> a;
|
||||
F(i,0,n) cin >> a[i];
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user