Submission #32325

#TimeUsernameProblemLanguageResultExecution timeMemory
32325dqhungdlFile Paths (BOI15_fil)C++14
0 / 100
0 ms2060 KiB
#include <bits/stdc++.h> using namespace std; int n,m,k,s,p[6005],l[6005]; vector<int> V; void Check(int u) { V.clear(); int sum=0; while(u>0) { V.push_back(l[u]); sum+=l[u]; u=p[u]; } reverse(V.begin(),V.end()); V.pop_back(); if(sum==k) { printf("YES\n"); return; } if(sum>k) { printf("NO\n"); return; } if((k-sum)%s==0) { printf("YES\n"); return; } for(int i=0;i<V.size();i++) { int sum1=s; for(int j=i;j<V.size();j++) { sum1+=V[j]; if((k-sum)%sum1==0) { printf("YES\n"); return; } } } printf("NO\n"); } void Sub2() { for(int i=n+1;i<=n+m;i++) Check(i); } int main() { //freopen("FIL.INP","r",stdin); scanf("%d%d%d%d",&n,&m,&k,&s); s++; for(int i=1;i<=n+m;i++) { scanf("%d%d",&p[i],&l[i]); l[i]++; } if(n<=3000&&m<=3000) Sub2(); }

Compilation message (stderr)

fil.cpp: In function 'void Check(int)':
fil.cpp:34:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<V.size();i++)
                  ^
fil.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=i;j<V.size();j++)
                      ^
fil.cpp: In function 'int main()':
fil.cpp:59:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d",&n,&m,&k,&s);
                                  ^
fil.cpp:63:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&p[i],&l[i]);
                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...