# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1082408 |
2024-08-31T09:55:32 Z |
hahahaha |
Robot (JOI21_ho_t4) |
C++17 |
|
261 ms |
132124 KB |
#include <bits/stdc++.h>
#define eb emplace_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll MAX=1e6+10;
const ll oo=0x3f3f3f3f3f3f3f3f;
ll n,m;
struct edge{
ll d,clr,cst;
edge(ll a,ll b,ll c):d(a),clr(b),cst(c){}
};
vector<edge> G[MAX];
vector<pll> G2[MAX*3];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>m;
for (int i=0;i<m;i++) {
ll a,b,c,p;
cin>>a>>b>>c>>p;
G[a].eb(b,c,p);
G[b].eb(a,c,p);
G2[a].eb(b,p);
G2[b].eb(a,p);
}
int now=n+1;
for (int i=1;i<=n;i++) {
map<int,vector<pll> > ttl;
for (auto eg:G[i]) ttl[eg.clr].eb(eg.d,eg.cst);
for (auto [clr,egs]:ttl) {
ll ttlw=0;
for (auto eg:egs) ttlw+=eg.S;
for (auto eg:egs) {
G2[i].eb(eg.F,ttlw-eg.S);
}
}
}
priority_queue<pll> D;
vector<bool> vis(now+1,0);
vector<ll> d(now+1,oo);
d[1]=0;
D.emplace(0,1);
while (!D.empty()) {
while (!D.empty() and vis[D.top().S]) D.pop();
if (D.empty()) break;
int v=D.top().S;
D.pop();
vis[v]=true;
for (auto [u,w]:G2[v]) {
if (!vis[u] and d[v]+w<d[u]) {
d[u]=d[v]+w;
D.emplace(-d[u],u);
}
}
}
cout<<(d[n]==oo?-1:d[n])<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
94288 KB |
Output is correct |
2 |
Correct |
25 ms |
94340 KB |
Output is correct |
3 |
Correct |
28 ms |
94344 KB |
Output is correct |
4 |
Correct |
26 ms |
94300 KB |
Output is correct |
5 |
Correct |
25 ms |
94300 KB |
Output is correct |
6 |
Correct |
31 ms |
94264 KB |
Output is correct |
7 |
Correct |
27 ms |
94360 KB |
Output is correct |
8 |
Correct |
25 ms |
94300 KB |
Output is correct |
9 |
Incorrect |
28 ms |
94544 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
108844 KB |
Output is correct |
2 |
Correct |
53 ms |
100756 KB |
Output is correct |
3 |
Correct |
95 ms |
118740 KB |
Output is correct |
4 |
Correct |
72 ms |
103764 KB |
Output is correct |
5 |
Incorrect |
261 ms |
132124 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
94288 KB |
Output is correct |
2 |
Correct |
25 ms |
94340 KB |
Output is correct |
3 |
Correct |
28 ms |
94344 KB |
Output is correct |
4 |
Correct |
26 ms |
94300 KB |
Output is correct |
5 |
Correct |
25 ms |
94300 KB |
Output is correct |
6 |
Correct |
31 ms |
94264 KB |
Output is correct |
7 |
Correct |
27 ms |
94360 KB |
Output is correct |
8 |
Correct |
25 ms |
94300 KB |
Output is correct |
9 |
Incorrect |
28 ms |
94544 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |