Submission #292743

# Submission time Handle Problem Language Result Execution time Memory
292743 2020-09-07T12:46:20 Z 반딧불(#5810) Express 20/19 (ROI19_express) C++17
0 / 100
9 ms 12320 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

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 9 ms 12288 KB Output is correct
2 Correct 8 ms 12288 KB Output is correct
3 Incorrect 9 ms 12320 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 12288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 12288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 12288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 12288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 12288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 12288 KB Output is correct
2 Correct 8 ms 12288 KB Output is correct
3 Incorrect 9 ms 12320 KB Output isn't correct
4 Halted 0 ms 0 KB -