| Task: | Ryhmät |
| Sender: | Metabolix |
| Submission time: | 2025-10-05 17:12:46 +0300 |
| Language: | C++ (C++20) |
| 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.12 s | 2 | details |
| #7 | ACCEPTED | 0.15 s | 2 | details |
| #8 | ACCEPTED | 0.28 s | 2 | details |
| #9 | ACCEPTED | 0.14 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 |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:95:18: warning: variable 'toive' set but not used [-Wunused-but-set-variable]
95 | auto toive = toiveet_alkaneet.begin()->second;
| ^~~~~Code
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <set>
#include <bitset>
using namespace std;
int main() {
ios::sync_with_stdio(false);
set<int> rajakohdat;
int n, t;
cin >> n >> t;
vector<array<int, 2>> toiveet(n);
for (int i = 0; i < n; i++) {
cin >> toiveet[i][0] >> toiveet[i][1];
toiveet[i][1] += 1;
rajakohdat.insert(toiveet[i][0]);
rajakohdat.insert(toiveet[i][1]);
}
set<int> testikohdat;
vector<map<int, int>> testit(t);
for (int i = 0; i < t; i++) {
int m;
cin >> m;
for (int j = 0; j < m; j++) {
int k;
cin >> k;
testit[i][k] += k;
testikohdat.insert(k);
}
}
// Poistetaan rajakohdat, joiden välissä ei ole testikohtaa
for (auto it = rajakohdat.begin(); it != rajakohdat.end();) {
auto next_it = next(it);
if (next_it == rajakohdat.end()) {
break;
}
int alku = *it;
int loppu = *next_it;
auto testi_olemassa = testikohdat.lower_bound(alku);
if (testi_olemassa == testikohdat.end() || *testi_olemassa >= loppu) {
rajakohdat.erase(it);
}
it = next_it;
}
map<int, int> muunnokset;
for (auto r : rajakohdat) {
muunnokset[r] = muunnokset.size();
}
for (auto& toive : toiveet) {
toive[0] = muunnokset.lower_bound(toive[0])->second;
toive[1] = muunnokset.lower_bound(toive[1])->second;
}
vector<array<int, 3>> vaiheet;
for (int i = 0; i < t; i++) {
auto testi = testit[i];
map<int, int> uusi;
for (auto [koko, lapsimäärä] : testi) {
uusi[muunnokset[koko]] += lapsimäärä;
}
testi = move(uusi);
for (auto &[koko, lapsimäärä] : testi) {
vaiheet.push_back({koko, lapsimäärä, i});
}
}
ranges::sort(vaiheet);
vector<unordered_set<int>> käytetyt(t);
vector<bool> tulokset(t, true);
multimap<int, array<int, 3>> toiveet_tulossa;
for (int i = 0; i < n; i++) {
toiveet_tulossa.insert({toiveet[i][0], {toiveet[i][0], toiveet[i][1], i}});
}
multimap<int, array<int, 3>> toiveet_alkaneet;
for (auto &[koko, lapsimäärä, testi] : vaiheet) {
if (tulokset[testi] == false) {
continue;
}
while (!toiveet_tulossa.empty() && toiveet_tulossa.begin()->first <= koko) {
auto toive = toiveet_tulossa.begin()->second;
toiveet_alkaneet.insert({toive[1], toive});
toiveet_tulossa.erase(toiveet_tulossa.begin());
}
while (!toiveet_alkaneet.empty() && toiveet_alkaneet.begin()->first <= koko) {
auto toive = toiveet_alkaneet.begin()->second;
toiveet_alkaneet.erase(toiveet_alkaneet.begin());
}
for (auto [loppu, toive] : toiveet_alkaneet) {
if (käytetyt[testi].find(toive[2]) == käytetyt[testi].end()) {
käytetyt[testi].insert(toive[2]);
lapsimäärä--;
if (lapsimäärä == 0) {
break;
}
}
}
if (lapsimäärä > 0) {
tulokset[testi] = false;
}
}
for (auto tulos : tulokset) {
if (tulos) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
}
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 ... Truncated |
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 ... Truncated |
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 ... Truncated |
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 ... Truncated |
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 ... Truncated |
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 ... Truncated |
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 ... Truncated |
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 ... Truncated |
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 ... Truncated |
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) |
