Submission #32325

# Submission time Handle Problem Language Result Execution time Memory
32325 2017-10-09T02:07:57 Z dqhungdl File Paths (BOI15_fil) C++14
0 / 100
0 ms 2060 KB
#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

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 time Memory Grader output
1 Incorrect 0 ms 2060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2060 KB Output isn't correct
2 Halted 0 ms 0 KB -