# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
512465 |
2022-01-16T11:25:52 Z |
Killer2501 |
Ceste (COCI17_ceste) |
C++14 |
|
371 ms |
17680 KB |
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 2e5+5;
const int M = (1<<17);
const ll inf = 1e15;
const int mod = 1e9+7;
int n, t, k, a[N], c[N], d[N], m;
ll ans, tong, b[N];
string s;
struct node
{
int id, x, y;
node(){}
node(int _id, int _x, int _y)
{
id = _id;
x = _x;
y = _y;
}
bool operator < (const node& u) const
{
return x > u.x;
}
};
vector<node> adj[N];
void sol()
{
cin >> n >> m;
while(m -- > 0)
{
int x, y, t, c;
cin >> x >> y >> t >> c;
adj[x].pb(node(y, t, c));
adj[y].pb(node(x, t, c));
}
fill_n(b, n+1, inf);
fill_n(d, n+1, mod);
priority_queue< node > pq;
pq.push(node(1, 0, 0));
while(!pq.empty())
{
node u = pq.top();
pq.pop();
//cout << u.id <<" "<<u.x <<" "<<u.y <<'\n';
if(u.y > d[u.id])continue;
d[u.id] = u.y;
b[u.id] = min(b[u.id], 1ll * u.x * u.y);
for(node v: adj[u.id])
{
pq.push(node(v.id, u.x+v.x, u.y+v.y));
}
}
for(int i = 2; i <= n; i ++)
{
if(b[i] == inf)cout << -1 << '\n';
else cout << b[i] << '\n';
}
}
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
#define task "test"
if(fopen(task".inp", "r"))
{
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int ntest = 1;
//cin >> ntest;
while(ntest -- > 0)
sol();
}
Compilation message
ceste.cpp: In function 'int main()':
ceste.cpp:75:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
75 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ceste.cpp:76:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
76 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
5072 KB |
Output is correct |
2 |
Correct |
5 ms |
5168 KB |
Output is correct |
3 |
Correct |
6 ms |
5328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
5964 KB |
Output is correct |
2 |
Correct |
39 ms |
5928 KB |
Output is correct |
3 |
Correct |
47 ms |
6044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
6784 KB |
Output is correct |
2 |
Correct |
371 ms |
17680 KB |
Output is correct |
3 |
Correct |
6 ms |
5428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
5668 KB |
Output is correct |
2 |
Correct |
222 ms |
8280 KB |
Output is correct |
3 |
Correct |
12 ms |
5200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
156 ms |
5640 KB |
Output is correct |
2 |
Correct |
166 ms |
6820 KB |
Output is correct |
3 |
Correct |
149 ms |
6760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
153 ms |
6744 KB |
Output is correct |
2 |
Correct |
146 ms |
6832 KB |
Output is correct |
3 |
Correct |
192 ms |
6788 KB |
Output is correct |