Submission #949353

#TimeUsernameProblemLanguageResultExecution timeMemory
949353MuhammadSaramFile Paths (BOI15_fil)C++17
0 / 100
7 ms1112 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define in binary_search #define int long long int s; bool check(vector<int> &v,int x) { if (x<s+1) return false; x-=s+1; for (int i=v.size()-2;v[i]>=x;i--) if (in(all(v),v[i]-x)) return true; return false; } signed main() { int n,m,k; cin>>n>>m>>k; cin>>s; int pd[n+1]={},pathd[n+1]={}; vector<int> pathf[m]; map<int,bool> pres; for (int i=1;i<=n;i++) { int a,b; cin>>a>>b; pd[i]=a; pathd[i]=pathd[a]+b+1; } for (int i=0;i<m;i++) { int a,b; cin>>a>>b; pathf[i].push_back(pathd[a]+b+1); while (a) { pathf[i].push_back(pathd[a]); a=pd[a]; } pathf[i].push_back(0); reverse(all(pathf[i])); for (int j=0;j+1<pathf[i].size();j++) pres[pathf[i][j]+s+1]=true; } for (int i=0;i<m;i++) { int x=pathf[i].back(); string ans="NO"; if (x==k) ans="YES"; else { for (int j=0;j+1<pathf[i].size();j++) if (pres.find(k-(x-pathf[i][j]))!=pres.end()) { ans="YES"; break; } } cout<<ans<<endl; } return 0; }

Compilation message (stderr)

fil.cpp: In function 'int main()':
fil.cpp:49:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for (int j=0;j+1<pathf[i].size();j++)
      |                ~~~^~~~~~~~~~~~~~~~
fil.cpp:60:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |    for (int j=0;j+1<pathf[i].size();j++)
      |                 ~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...