Submission #292745

# Submission time Handle Problem Language Result Execution time Memory
292745 2020-09-07T12:49:10 Z 반딧불(#5810) Express 20/19 (ROI19_express) C++17
15 / 100
12 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int t;
int n, m, q, p;
vector<pair<int, ll> > link[12];
set<ll> st[12];

int main(){
    scanf("%d", &t);
    while(t--){
        scanf("%d %d %d %d", &n, &m, &q, &p);
        for(int i=1; i<=n; i++) link[i].clear();
        for(int i=1; i<=m; i++){
            int x, y; ll d;
            scanf("%d %d %lld", &x, &y, &d);
            link[x].push_back({y, d});
        }

        for(int i=1; i<=n; i++) st[i].clear();
        st[1].insert(0);
        for(int i=1; i<=n; i++){
            for(auto nxt: link[i]){
                for(auto v: st[i]){
                    st[nxt.first].insert(v + nxt.second);
                }
            }
        }

        string s;
        for(int i=1; i<=q; i++){
            int f; ll r;
            scanf("%d %lld", &f, &r);
            auto it = st[f].lower_bound(r);
            if(it == st[f].end()){
                s.push_back('0');
                continue;
            }
            if(*it * (p-1) <= r * p) s.push_back('1');
            else s.push_back('0');
        }
        cout << s << endl;
    }
}

Compilation message

express.cpp: In function 'int main()':
express.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%d", &t);
      |     ~~~~~^~~~~~~~~~
express.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |         scanf("%d %d %d %d", &n, &m, &q, &p);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
express.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |             scanf("%d %d %lld", &x, &y, &d);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
express.cpp:36:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |             scanf("%d %lld", &f, &r);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 8 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 11 ms 384 KB Output is correct
13 Correct 12 ms 384 KB Output is correct
14 Correct 12 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 10 ms 384 KB Output is correct
17 Correct 10 ms 384 KB Output is correct
18 Correct 11 ms 384 KB Output is correct
19 Correct 12 ms 384 KB Output is correct
20 Correct 11 ms 384 KB Output is correct
21 Correct 10 ms 384 KB Output is correct
22 Correct 11 ms 384 KB Output is correct
23 Correct 9 ms 384 KB Output is correct
24 Correct 8 ms 384 KB Output is correct
25 Correct 8 ms 256 KB Output is correct
26 Correct 8 ms 384 KB Output is correct
27 Correct 8 ms 384 KB Output is correct
28 Correct 8 ms 384 KB Output is correct
29 Correct 9 ms 384 KB Output is correct
30 Correct 8 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Runtime error 1 ms 384 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Runtime error 1 ms 384 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Runtime error 1 ms 384 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Runtime error 1 ms 384 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Runtime error 1 ms 384 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 8 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 11 ms 384 KB Output is correct
13 Correct 12 ms 384 KB Output is correct
14 Correct 12 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 10 ms 384 KB Output is correct
17 Correct 10 ms 384 KB Output is correct
18 Correct 11 ms 384 KB Output is correct
19 Correct 12 ms 384 KB Output is correct
20 Correct 11 ms 384 KB Output is correct
21 Correct 10 ms 384 KB Output is correct
22 Correct 11 ms 384 KB Output is correct
23 Correct 9 ms 384 KB Output is correct
24 Correct 8 ms 384 KB Output is correct
25 Correct 8 ms 256 KB Output is correct
26 Correct 8 ms 384 KB Output is correct
27 Correct 8 ms 384 KB Output is correct
28 Correct 8 ms 384 KB Output is correct
29 Correct 9 ms 384 KB Output is correct
30 Correct 8 ms 384 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 0 ms 256 KB Output is correct
33 Correct 0 ms 256 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 0 ms 256 KB Output is correct
37 Correct 0 ms 256 KB Output is correct
38 Correct 0 ms 256 KB Output is correct
39 Correct 0 ms 256 KB Output is correct
40 Runtime error 1 ms 384 KB Execution killed with signal 11
41 Halted 0 ms 0 KB -