Add a bunch of other problems.

Some are not finished...
This commit is contained in:
2025-09-12 14:50:25 -03:00
parent 88e542c982
commit 489cb2ba51
385 changed files with 49442 additions and 0 deletions

View File

@@ -0,0 +1,193 @@
/* Problem URL: https://codeforces.com/gym/105231/problem/I */
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC target("bmi,bmi2,popcnt,lzcnt")
using namespace std;
#define V vector
#define rmin(a, b) a = min(a, b)
#define rmax(a, b) a = max(a, b)
#define rep(i, lim) for (int i = 0; i < (lim); i++)
#define nrep(i, s, lim) for (int i = s; i < (lim); i++)
#define repv(i, v) for (auto &i : (v))
#define fillv(v) for (auto &itr_ : (v)) { cin >> itr_; }
#define sortv(v) sort(v.begin(), v.end())
#define all(v) (v).begin(), (v).end()
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vvvvi = vector<vvvi>;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vvvvl = vector<vvvl>;
template<class v>
auto operator<<(ostream &os, const vector<v> &vec)->ostream& {
os << vec[0];
for (size_t i = 1; i < vec.size(); i++) {
os << ' ' << vec[i];
}
os << '\n';
return os;
}
template<class v>
auto operator>>(istream &is, vector<v> &vec)->istream& {
for (auto &i : vec) {
is >> i;
}
return is;
}
template<class v>
auto operator<<(ostream &os, const vector<vector<v>> &vec)->ostream& {
for (auto &i : vec) {
os << i[0];
for (size_t j = 1; j < i.size(); j++) {
os << ' ' << i[j];
}
os << '\n';
}
return os;
}
template<class v>
auto operator>>(istream &is, vector<vector<v>> &vec)->istream& {
for (auto &i : vec) {
for (auto &j : i) {
is >> j;
}
}
return is;
}
using pd = pair<double, double>;
pd operator+(pd a, pd b) {
pd fds = {a.first + b.first, a.second + b.second};
return fds;
}
pd operator-(pd a, pd b) {
pd fds = {a.first - b.first, a.second - b.second};
return fds;
}
pd operator/(pd a, double f) {
return make_pair(a.first / f, a.second / f);
}
pd operator*(pd a, double f) {
return make_pair(a.first * f, a.second * f);
}
pd rotate90(pd a) {
return pd(-a.second, a.first);
}
double operator^(pd a, pd b) {
return a.first * b.second - a.second * b.first;
}
struct line {
pd p, q;
};
double get_t(pd v, line r) {
return (r.p^r.q) / ((r.p - r.q)^v);
}
double EPS = 1e-6;
double inf = 1e18;
pd inter(line r, line s)
{
if (abs((r.p - r.q) ^ (s.p - s.q)) < EPS) {
return pd(inf, inf);
}
r.q = r.q - r.p, s.p = s.p - r.p, s.q = s.q - r.p;
return (r.q * get_t(r.q, s)) + r.p;
}
pd getcenter(pd a, pd b, pd c) {
b = (a + b) / 2;
c = (a + c) / 2;
return inter(line(b, b + rotate90(a - b)), line(c, c + rotate90(a - c)));
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
V<pair<double, double>> points(n);
repv(i, points) {
cin >> i.first >> i.second;
}
V<double> disses(n, 1e16);
auto dis = [&](pair<double, double> &a, pair<double, double> &b) {
double x = a.first - b.first;
double y = a.second - b.second;
return sqrt(x * x + y * y);
};
V<double> lol(n);
auto calc = [&](pair<double, double> center) {
rep(i, n) {
lol[i] = dis(center, points[i]);
}
};
auto search = [&](pair<double, double> point) {
sortv(lol);
nrep(i, 1, n) {
rmin(disses[i], lol[i]);
}
};
rep(i, n - 1) {
nrep(j, i + 1, n) {
pair<double, double> center = {(points[i].first + points[j].first) / 2, (points[i].second + points[j].second) / 2};
calc(center);
search(center);
}
}
rep(i, n - 2) {
nrep(j, i + 1, n - 1) {
nrep(k, j + 1, n) {
auto center = getcenter(points[i], points[j], points[k]);
calc(center);
search(center);
}
}
}
int act = 1;
nrep(i, 1, n) {
rep(j, act) {
cout << fixed << setprecision(8) << disses[i] << '\n';
}
act++;
}
}

View File

@@ -0,0 +1,231 @@
/* Problem URL: https://codeforces.com/gym/105231/problem/L */
#include <bits/stdc++.h>
using namespace std;
#define V vector
#define rmin(a, b) a = min(a, b)
#define rmax(a, b) a = max(a, b)
#define rep(i, lim) for (int i = 0; i < (lim); i++)
#define nrep(i, s, lim) for (int i = s; i < (lim); i++)
#define repv(i, v) for (auto &i : (v))
#define fillv(v) for (auto &itr_ : (v)) { cin >> itr_; }
#define sortv(v) sort(v.begin(), v.end())
#define all(v) (v).begin(), (v).end()
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vvvvi = vector<vvvi>;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vvvvl = vector<vvvl>;
template<class v>
auto operator<<(ostream &os, const vector<v> &vec)->ostream& {
os << vec[0];
for (size_t i = 1; i < vec.size(); i++) {
os << ' ' << vec[i];
}
os << '\n';
return os;
}
template<class v>
auto operator>>(istream &is, vector<v> &vec)->istream& {
for (auto &i : vec) {
is >> i;
}
return is;
}
template<class v>
auto operator<<(ostream &os, const vector<vector<v>> &vec)->ostream& {
for (auto &i : vec) {
os << i[0];
for (size_t j = 1; j < i.size(); j++) {
os << ' ' << i[j];
}
os << '\n';
}
return os;
}
template<class v>
auto operator>>(istream &is, vector<vector<v>> &vec)->istream& {
for (auto &i : vec) {
for (auto &j : i) {
is >> j;
}
}
return is;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k, t;
cin >> n >> m >> k >> t;
vl fds(n);
cin >> fds;
V<tuple<int, int, int>> gates;
rep(i, k) {
int n, l, r;
cin >> n >> l >> r;
n--;
gates.emplace_back(n, l, r);
}
ll inf = INT64_MAX >> 1;
vvl dis(n, vl(k, inf));
V<V<pair<int, ll>>> graph(n);
auto dijkstra = [&](int i, int k) {
priority_queue<pair<ll, int>, V<pair<ll, int>>, greater<>> pq;
dis[i][k] = 0;
pq.emplace(0, i);
while (!pq.empty()) {
auto [c, now] = pq.top();
pq.pop();
if (c > dis[now][k]) {
continue;
}
for (auto [j, cost] : graph[now]) {
if (dis[j][k] > cost + c) {
dis[j][k] = cost + c;
pq.emplace(cost + c, j);
}
}
}
};
while (m--) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
graph[a].emplace_back(b, c);
graph[b].emplace_back(a, c);
}
rep(i, k) {
dijkstra(get<0>(gates[i]), i);
}
vi pos(t + 2, 0);
for (auto [i, l, r] : gates) {
pos[l]++;
pos[r + 1]--;
}
nrep(i, 1, t) {
pos[i] += pos[i - 1];
}
vl ans(t + 2, 0);
rep(i, n) {
priority_queue<pair<ll, int>> pq;
rep(j, k) {
pq.emplace(dis[i][j], j);
}
set<tuple<ll, int ,int>> inter;
while (!pq.empty()) {
auto [c, j] = pq.top();
pq.pop();
auto [n, l, r] = gates[j];
auto itr = inter.begin();
while (itr != inter.end()) {
auto [cost, tl, tr] = *itr;
if (l <= tl && r >= tr) {
inter.erase(make_tuple(cost, tl, tr));
ans[tl] -= cost * fds[i];
ans[tr + 1] += cost * fds[i];
itr = inter.begin();
continue;
}
if (l >= tl && r <= tr) {
inter.erase(make_tuple(cost, tl, tr));
ans[tl] -= cost * fds[i];
ans[tr + 1] += cost * fds[i];
if (l - 1 >= tl) {
inter.emplace(cost, tl, l - 1);
ans[tl] += cost * fds[i];
ans[l] -= cost * fds[i];
}
if (r + 1 <= tr) {
inter.emplace(cost, r + 1, tr);
ans[r + 1] += cost * fds[i];
ans[tr + 1] -= cost * fds[i];
}
itr = inter.begin();
continue;
}
if (l >= tl && l <= tr) {
inter.erase(make_tuple(cost, tl, tr));
ans[tl] -= cost * fds[i];
ans[tr + 1] += cost * fds[i];
if (l - 1 >= tl) {
inter.emplace(cost, tl, l - 1);
ans[tl] += cost * fds[i];
ans[l] -= cost * fds[i];
}
itr = inter.begin();
continue;
}
if (r >= tl && r <= tr) {
inter.erase(make_tuple(cost, tl, tr));
ans[tl] -= cost * fds[i];
ans[tr + 1] += cost * fds[i];
if (r + 1 <= tr) {
inter.emplace(cost, r + 1, tr);
ans[r + 1] += cost * fds[i];
ans[tr + 1] -= cost * fds[i];
}
itr = inter.begin();
continue;
}
itr++;
}
inter.emplace(c, l, r);
ans[l] += c * fds[i];
ans[r + 1] -= c * fds[i];
}
}
for (int i = 1; i <= t; i++) {
ans[i] += ans[i - 1];
if (!pos[i]) {
cout << "-1\n";
continue;
}
cout << ans[i] << '\n';
}
}