Compare commits
2 Commits
2d314df46f
...
ccd62bc6e9
| Author | SHA1 | Date | |
|---|---|---|---|
| ccd62bc6e9 | |||
| 23630c1356 |
@@ -0,0 +1,223 @@
|
|||||||
|
/* Problem URL: https://codeforces.com/gym/102361/problem/A */
|
||||||
|
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
#include <ext/pb_ds/assoc_container.hpp>
|
||||||
|
#include <ext/pb_ds/tree_policy.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace __gnu_pbds;
|
||||||
|
|
||||||
|
template <class T, class comp = less<>>
|
||||||
|
using ordered_set = tree<T, null_type , comp , rb_tree_tag , tree_order_statistics_node_update>;
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int oo = INT32_MAX >> 1;
|
||||||
|
const ll OO = INT64_MAX >> 1;
|
||||||
|
|
||||||
|
struct pt {
|
||||||
|
ll x, y;
|
||||||
|
|
||||||
|
pt() = default;
|
||||||
|
pt(ll x, ll y): x(x), y(y) {}
|
||||||
|
|
||||||
|
friend istream &operator >> (istream &is, pt &a) {
|
||||||
|
is >> a.x >> a.y;
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
pt operator - (pt b) {
|
||||||
|
return pt(x - b.x, y - b.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
ll operator ^ (pt b) {
|
||||||
|
return x * b.y - y * b.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
ll operator * (pt b) {
|
||||||
|
return x * b.x + y * b.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (pt b) const {
|
||||||
|
if (x == b.x) {
|
||||||
|
return y < b.y;
|
||||||
|
}
|
||||||
|
return x < b.x;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int quad(pt a)
|
||||||
|
{
|
||||||
|
static const int q[][2] = {{0, 1}, {3, 2}};
|
||||||
|
return q[a.x < 0][a.y < 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
int ccw(pt a, pt b, pt c)
|
||||||
|
{
|
||||||
|
ll r = (b - a) ^ (c - b);
|
||||||
|
return (r > 0) - (r < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool polar_cmp(pt a, pt b)
|
||||||
|
{
|
||||||
|
if (quad(a) != quad(b)) {
|
||||||
|
return quad(a) < quad(b);
|
||||||
|
}
|
||||||
|
return ccw(pt(0, 0), a, b) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ll dot(pt a, pt b, pt c)
|
||||||
|
{
|
||||||
|
return (b - a) * (c - a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pre()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TEST 0
|
||||||
|
|
||||||
|
void solve()
|
||||||
|
{
|
||||||
|
int n, q;
|
||||||
|
cin >> n >> q;
|
||||||
|
|
||||||
|
V<pt> a(n + q);
|
||||||
|
cin >> a;
|
||||||
|
|
||||||
|
vl ans(q);
|
||||||
|
vi p(n + q);
|
||||||
|
iota(all(p), 0);
|
||||||
|
|
||||||
|
rep(i, n + q) {
|
||||||
|
sort(all(p), [&](int j, int k){
|
||||||
|
return polar_cmp(a[j] - a[i], a[k] - a[i]);
|
||||||
|
});
|
||||||
|
|
||||||
|
int j = 0;
|
||||||
|
int now = 1;
|
||||||
|
while (j < n + q) {
|
||||||
|
int p1 = p[j];
|
||||||
|
int p2 = p[now];
|
||||||
|
|
||||||
|
if (p1 == i) {
|
||||||
|
j++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (now == j || p2 == i) {
|
||||||
|
now = (now + 1) % (q + n);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ccw(a[i], a[p1], a[p2]) >= 0) {
|
||||||
|
j++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ll d = dot(a[i], a[p1], a[p2]);
|
||||||
|
|
||||||
|
if (d < 0) {
|
||||||
|
j++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d > 0) {
|
||||||
|
now = (now + 1) % (q + n);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i >= n && p1 < n && p2 < n) {
|
||||||
|
ans[i - n]++;
|
||||||
|
} else if (i < n && p1 >= n && p2 < n) {
|
||||||
|
ans[p1 - n]++;
|
||||||
|
} else if (i < n && p1 < n && p2 >= n) {
|
||||||
|
ans[p2 - n]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repv(i, ans) {
|
||||||
|
cout << i << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
pre();
|
||||||
|
|
||||||
|
int t;
|
||||||
|
(TEST && cin >> t) || (t = 1);
|
||||||
|
while (t--) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
/* Problem URL: https://codeforces.com/contest/2207/problem/B */
|
||||||
|
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
#include <ext/pb_ds/assoc_container.hpp>
|
||||||
|
#include <ext/pb_ds/tree_policy.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace __gnu_pbds;
|
||||||
|
|
||||||
|
template <class T, class comp = less<>>
|
||||||
|
using ordered_set = tree<T, null_type , comp , rb_tree_tag , tree_order_statistics_node_update>;
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int oo = INT32_MAX >> 1;
|
||||||
|
const ll OO = INT64_MAX >> 1;
|
||||||
|
|
||||||
|
|
||||||
|
void pre()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TEST 1
|
||||||
|
|
||||||
|
void solve()
|
||||||
|
{
|
||||||
|
int n, m, l;
|
||||||
|
cin >> n >> m >> l;
|
||||||
|
|
||||||
|
vi rem(l);
|
||||||
|
rep(i, n) {
|
||||||
|
int a;
|
||||||
|
cin >> a;
|
||||||
|
rem[a - 1] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
multiset<int> pq;
|
||||||
|
rep(i, min(n + 1, m)) {
|
||||||
|
pq.insert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int c = n;
|
||||||
|
|
||||||
|
rep(i, l) {
|
||||||
|
while (pq.size() > c + 1) {
|
||||||
|
pq.erase(pq.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto itr = pq.begin();
|
||||||
|
int val = *itr;
|
||||||
|
pq.erase(itr);
|
||||||
|
pq.insert(val + 1);
|
||||||
|
|
||||||
|
if (rem[i]) {
|
||||||
|
pq.erase(prev(pq.end()));
|
||||||
|
pq.insert(0);
|
||||||
|
c--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << *prev(pq.end()) << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
pre();
|
||||||
|
|
||||||
|
int t;
|
||||||
|
(TEST && cin >> t) || (t = 1);
|
||||||
|
while (t--) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
||||||
106
Codeforces Round 1085 (Div. 1 + Div. 2)/C. Where's My Water?.cpp
Normal file
106
Codeforces Round 1085 (Div. 1 + Div. 2)/C. Where's My Water?.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/* Problem URL: https://codeforces.com/contest/2207/problem/C */
|
||||||
|
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
#include <ext/pb_ds/assoc_container.hpp>
|
||||||
|
#include <ext/pb_ds/tree_policy.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace __gnu_pbds;
|
||||||
|
|
||||||
|
template <class T, class comp = less<>>
|
||||||
|
using ordered_set = tree<T, null_type , comp , rb_tree_tag , tree_order_statistics_node_update>;
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int oo = INT32_MAX >> 1;
|
||||||
|
const ll OO = INT64_MAX >> 1;
|
||||||
|
|
||||||
|
|
||||||
|
void pre()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TEST 1
|
||||||
|
|
||||||
|
void solve()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
pre();
|
||||||
|
|
||||||
|
int t;
|
||||||
|
(TEST && cin >> t) || (t = 1);
|
||||||
|
while (t--) {
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user