Task: | Ryhmät |
Sender: | sharph2 |
Submission time: | 2025-09-27 00:17:35 +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.06 s | 2 | details |
#7 | ACCEPTED | 0.07 s | 2 | details |
#8 | ACCEPTED | 0.14 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; template <typename F> void hajotelma_(int a, int b, const F& f, int v, int s) { if(b <= 0 || a >= s) { return; } if(a <= 0 && b >= s) { f(v); return; } int h = s >> 1; hajotelma_(a, b, f, 2 * v, h); hajotelma_(a - h, b - h, f, 2 * v + 1, h); } template <typename F> void hajotelma(int a, int b, const F& f) { hajotelma_(a, b + 1, f, 1, N); } template <typename F> void peitto(int i, const F& f) { i += N; while(i > 0) { f(i); i >>= 1; } } struct Solmu { vector<pair<int, int>> toiveet; int p = 0; }; int main() { cin.sync_with_stdio(false); cin.tie(nullptr); int n, t; cin >> n >> t; vector<Solmu> toivepuu(2 * N); for(int i = 0; i < n; ++i) { int a, b; cin >> a >> b; hajotelma(a, b, [&](int v) { toivepuu[v].toiveet.push_back({b, i}); }); } vector<bool> valittu(n); for(Solmu& solmu : toivepuu) { sort(solmu.toiveet.begin(), solmu.toiveet.end()); } 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; peitto(koko, [&](int v) { Solmu& solmu = toivepuu[v]; while(solmu.p < (int)solmu.toiveet.size() && valittu[solmu.toiveet[solmu.p].second]) { if(solmu.p == 0) { sotketutSolmut.push_back(v); } ++solmu.p; } if(solmu.p < (int)solmu.toiveet.size() && solmu.toiveet[solmu.p].first < paras) { paras = solmu.toiveet[solmu.p].first; parasV = v; } }); 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) |