# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
292769 | 2020-09-07T13:11:43 Z | 반딧불(#5810) | 급행열차 20/19 (ROI19_express) | C++17 | 487 ms | 64248 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<pair<ll, ll> > st[500002]; int qf[500002]; ll qr[500002]; 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<=q; i++){ scanf("%d %lld", &qf[i], &qr[i]); } ll diff = qr[1] / (p-1); for(int i=1; i<=n; i++) st[i].clear(); st[1].insert({-diff, 0LL}); for(int i=1; i<=n; i++){ // printf("i %d: ", i); // for(auto v: st[i]) printf("%lld~%lld, ", v.first, v.second); // puts(""); for(auto nxt: link[i]){ for(auto v: st[i]){ if(v.first + nxt.second <= qr[1]){ auto tmp = make_pair(v.first + nxt.second, v.second + nxt.second); auto it = st[nxt.first].lower_bound(tmp); if(it != st[nxt.first].end() && it->first-1 <= tmp.second){ tmp.second = max(tmp.second, it->second); st[nxt.first].erase(it); it = st[nxt.first].lower_bound(tmp); } if(it != st[nxt.first].begin() && tmp.first-1 <= prev(it)->second){ tmp.first = min(tmp.first, prev(it)->first); st[nxt.first].erase(prev(it)); } st[nxt.first].insert(tmp); } } } } for(int i=1; i<=q; i++){ if(st[qf[i]].empty()) printf("0"); else{ auto tmp = *st[qf[i]].rbegin(); if(tmp.first <= qr[i] && qr[i] <= tmp.second) printf("1"); else printf("0"); } } puts(""); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 35584 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 35492 KB | Output is correct |
2 | Correct | 26 ms | 35584 KB | Output is correct |
3 | Correct | 24 ms | 35596 KB | Output is correct |
4 | Correct | 25 ms | 35576 KB | Output is correct |
5 | Correct | 22 ms | 35584 KB | Output is correct |
6 | Correct | 23 ms | 35584 KB | Output is correct |
7 | Correct | 25 ms | 35584 KB | Output is correct |
8 | Correct | 27 ms | 35592 KB | Output is correct |
9 | Correct | 23 ms | 35584 KB | Output is correct |
10 | Incorrect | 27 ms | 35712 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 35584 KB | Output is correct |
2 | Correct | 487 ms | 64248 KB | Output is correct |
3 | Correct | 364 ms | 41336 KB | Output is correct |
4 | Incorrect | 357 ms | 38392 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 35584 KB | Output is correct |
2 | Correct | 487 ms | 64248 KB | Output is correct |
3 | Correct | 364 ms | 41336 KB | Output is correct |
4 | Incorrect | 357 ms | 38392 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 35576 KB | Output is correct |
2 | Correct | 22 ms | 35576 KB | Output is correct |
3 | Correct | 26 ms | 35584 KB | Output is correct |
4 | Correct | 27 ms | 35584 KB | Output is correct |
5 | Correct | 27 ms | 35584 KB | Output is correct |
6 | Correct | 27 ms | 35584 KB | Output is correct |
7 | Correct | 24 ms | 35584 KB | Output is correct |
8 | Correct | 31 ms | 36864 KB | Output is correct |
9 | Correct | 28 ms | 35712 KB | Output is correct |
10 | Incorrect | 24 ms | 35584 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 35576 KB | Output is correct |
2 | Correct | 22 ms | 35576 KB | Output is correct |
3 | Correct | 26 ms | 35584 KB | Output is correct |
4 | Correct | 27 ms | 35584 KB | Output is correct |
5 | Correct | 27 ms | 35584 KB | Output is correct |
6 | Correct | 27 ms | 35584 KB | Output is correct |
7 | Correct | 24 ms | 35584 KB | Output is correct |
8 | Correct | 31 ms | 36864 KB | Output is correct |
9 | Correct | 28 ms | 35712 KB | Output is correct |
10 | Incorrect | 24 ms | 35584 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 35584 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |