Submission #34396

# Submission time Handle Problem Language Result Execution time Memory
34396 2017-11-10T21:52:18 Z imaxblue File Paths (BOI15_fil) C++14
0 / 100
1000 ms 3400 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, t, a, b;
vector<pii> v[6005];
vector<ll> s;
bool p[1000005], u[3005];
void dfs2(int N, ll D){
    fox(l, v[N].size()){
        dfs2(v[N][l].x, D+v[N][l].y);
    }
    if (N<=n && D+t<=k){
        p[D+t]=1;
        //cout << D+t << endl;
    }
}
void dfs(int N, ll D){
    if (N>n){
        //cout << N << ' ' << D << endl;
        //fox(l, s.size()) cout << s[l] << ' '; cout << endl;
        if (D==k){
            u[N-n]=1;
            return;
        }
        fox(l, s.size()){
            if (D-s[l]<=k && p[k-(D-s[l])]){
                u[N-n]=1;
                return;
            }
        }
        fox(l, s.size()){
            for (int l2=l+1; l2<s.size(); ++l2){
                if ((k-D)>0 && (k-D)%(s[l2]-s[l]+t)==0){
                    u[N-n]=1;
                    return;
                }
            }
        }
        return;
    }
    s.pb(D);
    fox(l, v[N].size()){
        dfs(v[N][l].x, D+v[N][l].y);
    }
    s.pop_back();
}
int main(){
    cin >> n >> m >> k >> t;
    ++t;
    fox1(l, n){
        cin >> a >> b;
        v[a].pb(mp(l, b+1));
    }
    fox1(l, m){
        cin >> a >> b;
        v[a].pb(mp(l+n, b+1));
    }
    dfs2(0, 0);
    dfs(0, 0);
    fox1(l, m){
        if (u[l]) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}

Compilation message

fil.cpp: In function 'void dfs2(int, long long 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:32:5: note: in expansion of macro 'fox'
     fox(l, v[N].size()){
     ^
fil.cpp: In function 'void dfs(int, long long 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:48:9: note: in expansion of macro 'fox'
         fox(l, s.size()){
         ^
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:54:9: note: in expansion of macro 'fox'
         fox(l, s.size()){
         ^
fil.cpp:55:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int l2=l+1; l2<s.size(); ++l2){
                                ^
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:65:5: note: in expansion of macro 'fox'
     fox(l, v[N].size()){
     ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3136 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3268 KB Output is correct
2 Correct 0 ms 3268 KB Output is correct
3 Correct 3 ms 3268 KB Output is correct
4 Correct 0 ms 3268 KB Output is correct
5 Execution timed out 1000 ms 3400 KB Execution timed out
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3136 KB Output isn't correct
2 Halted 0 ms 0 KB -