# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1021739 | guagua0407 | File Paths (BOI15_fil) | C++17 | 245 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
const int mxn=1e6+5;
int main() {_
int n,m,k;
cin>>n>>m>>k;
int len;
cin>>len;
len++;
vector<ll> pre(n+1);
vector<int> p(n+1);
for(int i=1;i<=n;i++){
int l;
cin>>p[i]>>l;
pre[i]=pre[p[i]]+l+1;
}
vector<bitset<mxn>> b(n+1);
b[0][0]=1;
for(int i=0;i<=n;i++){
b[i]=b[p[i]];
for(int j=pre[i]+len;j<mxn;j++){
b[i][j]=b[i][j]|b[i][j-(pre[i]+len)];
}
}
for(int i=0;i<m;i++){
int pp,l;
cin>>pp>>l;
int cur=pre[pp]+l+1;
//cout<<cur<<'\n';
if(cur<=k and b[pp][k-cur]){
cout<<"YES"<<'\n';
}
else{
cout<<"NO"<<'\n';
}
}
return 0;
}
//maybe its multiset not set
//yeeorz
//laborz
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |