Submission #31421

# Submission time Handle Problem Language Result Execution time Memory
31421 2017-08-22T14:18:49 Z imaxblue File Paths (BOI15_fil) C++14
0 / 100
3 ms 6128 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()

int n, m, k, x, p, d, t;
int u[1000005];
bool ans[6005];
vector<pii> v[3005];
vector<int> pl;
void dfs2(int N, int D, int F){
    //cout << "*" << N << ' ' << D << ' ' << v[N].size()<< endl;
    if (D-pl.back()+x<=1000000) u[D-pl.back()+x]+=F;
    fox(l, v[N].size()){
        dfs2(v[N][l].x, D+v[N][l].y+1, F);
    }
}
void dfs(int N, int D){
    //cout << "*" << N << ' ' << D << ' ' << v[N].size()<< endl;
    if (N>n){
        t=k-D;
        if (t<0) return;
        if (t==0) ans[N]=1;
        //cout << N << ' ' << t << endl;
        for (int l=1; l*l<=t; ++l){
            if (t%l==0){
                if (u[t/l] || u[l]) ans[N]=1;
            }
        }
        return;
    }
    pl.pb(D);
    dfs2(N, D, 1);
    fox(l, v[N].size()){
        dfs(v[N][l].x, D+v[N][l].y+1);
    }
    dfs2(N, D, -1);
    pl.pop_back();
}
int main(){
    scanf("%i%i%i%i", &n, &m, &k, &x);
    ++x; u[x]++;
    fox1(l, n+m){
        scanf("%i%i", &p, &d);
        v[p].pb(mp(l, d));
    }
    dfs(0, 0);
    for (int l=n+1; l<=n+m; ++l){
        if (ans[l]) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Compilation message

fil.cpp: In function 'void dfs2(int, int, int)':
fil.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
                                  ^
fil.cpp:35:5: note: in expansion of macro 'fox'
     fox(l, v[N].size()){
     ^
fil.cpp: In function 'void dfs(int, int)':
fil.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
                                  ^
fil.cpp:55:5: note: in expansion of macro 'fox'
     fox(l, v[N].size()){
     ^
fil.cpp: In function 'int main()':
fil.cpp:62:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i%i", &n, &m, &k, &x);
                                      ^
fil.cpp:65:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i", &p, &d);
                              ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 5996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 6128 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 5996 KB Output isn't correct
2 Halted 0 ms 0 KB -