QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137438 | #6627. Line Town | penguinman# | 0 | 0ms | 3564kb | C++17 | 1.6kb | 2023-08-10 12:43:42 | 2024-07-04 01:29:12 |
Judging History
answer
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define pb emplace_back
#define mp std::make_pair
#define all(a) a.begin(),a.end()
#define mtp std::make_tuple
constexpr ll inf = (1ll<<60);
int main(){
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
ll N,M; cin >> N >> M;
vii revedge(N), weight(N), add(N);
rep(i,0,M){
ll u,v,r,p; cin >> u >> v >> r >> p;
revedge[--v].pb(--u);
weight[v].pb(r);
add[v].pb(p);
}
assert(N <= 2000 && M <= 2000);
vii dist(N,vi(N+10,inf));
std::priority_queue<std::tuple<ll,ll,ll>> que;
rep(i,0,N){
dist[i][0] = 0;
que.push(mtp(0,i,0));
}
while(!que.empty()){
ll now, d, val;
std::tie(val, now, d) = que.top(); que.pop();
val = -val;
if(val > dist[now][d]) continue;
if(d == N+9) continue;
rep(i,0,revedge[now].size()){
ll next = revedge[now][i];
ll nval = std::max(val-add[now][i], weight[now][i]);
if(dist[next][d+1] > nval){
dist[next][d+1] = nval;
que.push(mtp(-nval, next, d+1));
}
}
}
rep(i,0,N){
ll ans = dist[i][N+9];
if(ans == inf) ans = -1;
cout << ans << " ";
}
cout << ln;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
10 1 1 1 1 1 -1 -1 -1 1 -1
output:
1 -1 -1 -1 -1 -1 -1 -1 -1 -1
result:
wrong answer 1st numbers differ - expected: '-1', found: '1'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Runtime Error
Test #60:
score: 0
Runtime Error
input:
10 3 10 5 -9 7 2 -6 1 8 0
output:
result:
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%