Submission
Status:
[-S][PP][-SS][P-S][-SS][-SSSS][-SSSSSS][-SSS][-SSS][-SSSS]
Subtask/Task Score:
{0/10}{10/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}
Score: 10
User: anonymous
Problemset: ช่องบนไม้
Language: cpp
Time: 0.129 second
Submitted On: 2026-10-27 09:58:03
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,w,l; cin >> n >> w >> l;
vector<set<int>> pos(n);
for(int i=0;i<n;i++){
int k; cin >> k;
set<int> cur;
for(int j=0;j<k;j++){
int hole; cin >> hole;
for(int k=-1;k<=l;k++){
int p = hole + k;
if(p >= 1 && p <= w) cur.insert(p);
}
}
if(cur.empty()){
cout << 0;
return 0;
}
pos[i] = move(cur);
}
set<int> ans = pos[0];
for(int i=1;i<n;i++){
set<int> nex;
auto a = ans.begin();
auto b = pos[i].begin();
while (a != ans.end() && b != pos[i].end()){
if(*a < *b)b++;
else if(*b < *a)b++;
else{
nex.insert(*a);
a++;
b++;
}
}
ans = move(nex);
if(ans.empty()){
cout << 0;
return 0;
}
}
cout << 1;
}