Task: | Ryhmät |
Sender: | sharph2 |
Submission time: | 2025-09-27 00:57:40 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 25 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 10 |
#2 | ACCEPTED | 15 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#5 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#6 | ACCEPTED | 0.05 s | 2 | details |
#7 | ACCEPTED | 0.07 s | 2 | details |
#8 | ACCEPTED | 0.12 s | 2 | details |
#9 | ACCEPTED | 0.05 s | 2, 3 | details |
#10 | TIME LIMIT EXCEEDED | -- | 3 | details |
#11 | TIME LIMIT EXCEEDED | -- | 3 | details |
#12 | TIME LIMIT EXCEEDED | -- | 3 | details |
#13 | TIME LIMIT EXCEEDED | -- | 3 | details |
#14 | TIME LIMIT EXCEEDED | -- | 3 | details |
#15 | TIME LIMIT EXCEEDED | -- | 3 | details |
#16 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <algorithm> #include <iostream> #include <set> #include <stack> #include <queue> #include <vector> using namespace std; constexpr int N = 1 << 17; struct Solmu { pair<int, int>* toiveet; int toiveLkm = 0; int p = 0; }; pair<int, int> toivePuskuri[50 * N]; Solmu toivepuu[2 * N]; bool valittu[N]; void lisaa_(int a, int b, pair<int, int> toive, int v, int s) { if(b <= 0 || a >= s) { return; } if(a <= 0 && b >= s) { toivepuu[v].toiveet[--toivepuu[v].p] = toive; return; } int h = s >> 1; lisaa_(a, b, toive, 2 * v, h); lisaa_(a - h, b - h, toive, 2 * v + 1, h); } void lisaa(int a, int b, pair<int, int> toive) { lisaa_(a, b + 1, toive, 1, N); } void lisaa_(int a, int b, int v, int s) { if(b <= 0 || a >= s) { return; } if(a <= 0 && b >= s) { ++toivepuu[v].toiveLkm; return; } int h = s >> 1; lisaa_(a, b, 2 * v, h); lisaa_(a - h, b - h, 2 * v + 1, h); } void lisaa(int a, int b) { lisaa_(a, b + 1, 1, N); } int main() { cin.sync_with_stdio(false); cin.tie(nullptr); int n, t; cin >> n >> t; vector<pair<int, int>> toiveet(n); for(int i = 0; i < n; ++i) { cin >> toiveet[i].first >> toiveet[i].second; } sort(toiveet.begin(), toiveet.end(), [&](pair<int, int> a, pair<int, int> b) { return a.second > b.second; }); for(auto [a, b] : toiveet) { lisaa(a, b); } pair<int, int>* puskuriLoppu = toivePuskuri; for(Solmu& solmu : toivepuu) { solmu.toiveet = puskuriLoppu; puskuriLoppu += solmu.toiveLkm; solmu.p = solmu.toiveLkm; } for(int i = 0; i < n; ++i) { auto [a, b] = toiveet[i]; lisaa(a, b, {b, i}); } vector<int> koot; vector<int> sotketutSolmut; vector<int> valitut; for(int ti = 0; ti < t; ++ti) { int m; cin >> m; koot.resize(m); for(int i = 0; i < m; ++i) { cin >> koot[i]; } sort(koot.begin(), koot.end()); sotketutSolmut.clear(); valitut.clear(); bool ok = true; for(int koko : koot) { for(int toisto = 0; toisto < koko; ++toisto) { int paras = N; int parasV = -1; int v = koko + N; while(v > 0) { Solmu& solmu = toivepuu[v]; while(solmu.p < solmu.toiveLkm && valittu[solmu.toiveet[solmu.p].second]) { if(solmu.p == 0) { sotketutSolmut.push_back(v); } ++solmu.p; } if(solmu.p < solmu.toiveLkm && solmu.toiveet[solmu.p].first < paras) { paras = solmu.toiveet[solmu.p].first; parasV = v; } v >>= 1; } if(parasV == -1) { ok = false; goto ohi; } Solmu& solmu = toivepuu[parasV]; int i = solmu.toiveet[solmu.p].second; valittu[i] = true; valitut.push_back(i); } } ohi: {} if(ok) { cout << "YES\n"; } else { cout << "NO\n"; } for(int i : valitut) { valittu[i] = false; } for(int v : sotketutSolmut) { toivepuu[v].p = 0; } } return 0; }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 10 10 10 10 6 9 6 8 ... |
correct output |
---|
YES YES YES NO YES ... |
user output |
---|
YES YES YES NO YES ... |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 9 9 6 10 8 10 8 8 ... |
correct output |
---|
NO YES NO YES NO ... |
user output |
---|
NO YES NO YES NO ... |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 1 1 1 1 1 1 1 1 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES YES YES ... |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 100 100 100 100 100 100 100 100 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES YES YES ... |
Test 5
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 100 4 9 3 8 7 9 7 9 ... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
NO NO NO NO NO ... |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 9 10 2 5 10 10 5 5 ... |
correct output |
---|
YES YES YES YES NO ... |
user output |
---|
YES YES YES YES NO ... |
Test 7
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 5 7 9 9 3 7 8 10 ... |
correct output |
---|
YES NO NO YES YES ... |
user output |
---|
YES NO NO YES YES ... |
Test 8
Group: 2
Verdict: ACCEPTED
input |
---|
1000 1000 1 1 1 1 1 1 1 1 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES YES YES ... |
Test 9
Group: 2, 3
Verdict: ACCEPTED
input |
---|
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
YES YES YES YES YES ... |
Test 10
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 1000 774 778 363 852 309 668 261 459 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
(empty) |
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 1000 1233 1914 901 3963 1277 4293 1083 1599 ... |
correct output |
---|
NO NO YES NO NO ... |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 1000 1970 8631 4606 5797 6317 8162 8204 8789 ... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
(empty) |
Test 13
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 1000 1000 1000 1000 1000 1000 1000 1000 1000 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
(empty) |
Test 14
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 100000 1 100000 1 100000 1 100000 1 100000 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
(empty) |
Test 15
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 100000 80971 98445 93046 96043 74840 94035 95931 96609 ... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
(empty) |
Test 16
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 10000 6481 14350 69129 87600 6217 16462 4387 16625 ... |
correct output |
---|
YES YES YES YES YES ... |
user output |
---|
(empty) |