| Task: | Ryhmät |
| Sender: | Sisuaski |
| Submission time: | 2025-10-13 21:41:44 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 10 |
| #2 | ACCEPTED | 15 |
| #3 | ACCEPTED | 75 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.14 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.14 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.16 s | 1, 2, 3 | details |
| #4 | ACCEPTED | 0.14 s | 1, 2, 3 | details |
| #5 | ACCEPTED | 0.15 s | 1, 2, 3 | details |
| #6 | ACCEPTED | 0.22 s | 2 | details |
| #7 | ACCEPTED | 0.27 s | 2 | details |
| #8 | ACCEPTED | 0.80 s | 2 | details |
| #9 | ACCEPTED | 0.15 s | 2, 3 | details |
| #10 | ACCEPTED | 0.46 s | 3 | details |
| #11 | ACCEPTED | 0.46 s | 3 | details |
| #12 | ACCEPTED | 0.41 s | 3 | details |
| #13 | ACCEPTED | 0.37 s | 3 | details |
| #14 | ACCEPTED | 0.34 s | 3 | details |
| #15 | ACCEPTED | 0.54 s | 3 | details |
| #16 | ACCEPTED | 0.47 s | 3 | details |
Compiler report
input/code.cpp: In function 'std::vector<int> makeIdx(std::span<const int>, std::span<const int>)':
input/code.cpp:21:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::span<const int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | while(i < cs.size() && cs[i] < x) ++i;
| ~~^~~~~~~~~~~Code
#include <iostream>
#include <algorithm>
#include <vector>
#include <span>
using namespace std;
const int MN = 1<<19;
struct T {
vector<int> xs;
vector<int> li;
vector<int> ri;
};
T tree[2*MN];
vector<int> makeIdx(span<const int> ps, span<const int> cs) {
vector<int> res;
res.reserve(ps.size()+1);
int i=0;
for(int x: ps) {
while(i < cs.size() && cs[i] < x) ++i;
res.push_back(i);
}
res.push_back(cs.size());
return res;
}
void add(int x, int y) {
for(y+=MN; y>=1; y/=2) {
tree[y].xs.push_back(x);
}
}
int rcount(int i1, int i2, int y1, int y2, int i, int l, int r) {
if (l>=y1 && r<=y2) return i2-i1;
if (r<=y1 || l>=y2) return 0;
int m = (l+r)/2;
return rcount(tree[i].li[i1],tree[i].li[i2],y1,y2,2*i,l,m)
+ rcount(tree[i].ri[i1],tree[i].ri[i2],y1,y2,2*i+1,m,r);
}
int count(int x1, int x2, int y1, int y2) {
int i1 = lower_bound(tree[1].xs.begin(), tree[1].xs.end(), x1) - tree[1].xs.begin();
int i2 = lower_bound(tree[1].xs.begin(), tree[1].xs.end(), x2) - tree[1].xs.begin();
return rcount(i1,i2,y1,y2,1,0,MN);
}
int findy(int x1, int x2, int c) {
int i1 = lower_bound(tree[1].xs.begin(), tree[1].xs.end(), x1) - tree[1].xs.begin();
int i2 = lower_bound(tree[1].xs.begin(), tree[1].xs.end(), x2) - tree[1].xs.begin();
int i=1;
int y=0;
for(int w=MN/2;w>=1;w/=2) {
int lc = tree[i].li[i2] - tree[i].li[i1];
if (lc >= c) {
i1 = tree[i].li[i1];
i2 = tree[i].li[i2];
i = 2*i;
} else {
c -= lc;
i1 = tree[i].ri[i1];
i2 = tree[i].ri[i2];
i = 2*i+1;
y += w;
}
}
return y;
}
void build() {
for(T& t: tree) sort(t.xs.begin(),t.xs.end());
for(int i=1; i<MN; ++i) {
tree[i].li = makeIdx(tree[i].xs, tree[2*i].xs);
tree[i].ri = makeIdx(tree[i].xs, tree[2*i+1].xs);
}
}
struct S {
int x;
int y;
};
S stack[MN];
typedef pair<int,int> P;
P ps[MN];
int ks[MN];
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
int n,t;cin>>n>>t;
for(int i=0;i<n;++i) cin>>ps[i].second>>ps[i].first;
sort(ps,ps+n);
for(int i=0; i<n; ++i) add(ps[i].second,i+1);
build();
while(t--) {
int m;cin>>m;
for(int i=0; i<m; ++i) cin>>ks[i];
sort(ks,ks+m);
bool ok=1;
int z=0;
stack[z++] = {0,MN};
for(int i=0; i<m && ok; ++i) {
int k = ks[i];
if (k != stack[z-1].x) {
int y = lower_bound(ps,ps+n,P(k,0))-ps;
while(stack[z-1].y <= y) --z;
stack[z++] = {k, y};
}
ok = 0;
while(z>1) {
int a = count(stack[z-2].x+1, stack[z-1].x+1, stack[z-1].y+1, stack[z-2].y+1);
if (a>=k) {
int p = count(stack[z-2].x+1, stack[z-1].x+1, 0, stack[z-1].y+1);
stack[z-1].y = findy(stack[z-2].x+1, stack[z-1].x+1, p + k);
ok=1;
break;
} else {
k -= a;
--z;
stack[z-1].x = stack[z].x;
}
}
}
cout<<(ok?"YES\n":"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: ACCEPTED
| input |
|---|
| 100000 1000 774 778 363 852 309 668 261 459 ... |
| correct output |
|---|
| YES YES YES YES YES ... |
| user output |
|---|
| YES YES YES YES YES ... Truncated |
Test 11
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 1000 1233 1914 901 3963 1277 4293 1083 1599 ... |
| correct output |
|---|
| NO NO YES NO NO ... |
| user output |
|---|
| NO NO YES NO NO ... Truncated |
Test 12
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 1000 1970 8631 4606 5797 6317 8162 8204 8789 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... Truncated |
Test 13
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 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 14
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 1 100000 1 100000 1 100000 1 100000 ... |
| correct output |
|---|
| YES YES YES YES YES ... |
| user output |
|---|
| YES YES YES YES YES ... Truncated |
Test 15
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 100000 80971 98445 93046 96043 74840 94035 95931 96609 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... Truncated |
Test 16
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 10000 6481 14350 69129 87600 6217 16462 4387 16625 ... |
| correct output |
|---|
| YES YES YES YES YES ... |
| user output |
|---|
| YES YES YES YES YES ... Truncated |
