10617 | 2024-04-06 19:29:06 | Ablablabla | Autópálya infláció | cpp17 | Wrong answer 0/100 | 10ms | 8828 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int INF = 2e9 + 7;
const int MOD = 1e9 + 7;
int main()
{
int n, m;
cin >> n >> m;
vector<vector<pii>> csucsok(n, vector<pii>());
for(int i = 0; i < m; i++){
int a, b, c;
cin >> a >> b >> c;
a--; b--;
csucsok[a].push_back({b, c});
csucsok[b].push_back({a, c});
}
vector<int> szorzo(n + 1);
szorzo[0] = 1;
for(int i = 1; i <= n; i++){
szorzo[i] = 2 * szorzo[i - 1];
szorzo[i] %= MOD;
}
queue<int> bejar;
vector<int> tavok(n, INF);
bejar.push(0);
tavok[0] = 0;
vector<int> melyseg(n, 0);
while(!bejar.empty()){
int akt = bejar.front();
bejar.pop();
for(pii x : csucsok[akt]){
int ert = tavok[akt] + x.second * szorzo[melyseg[akt]];
ert %= MOD;
if(tavok[x.first] > ert){
tavok[x.first] = ert;
melyseg[x.first] = melyseg[akt] + 1;
bejar.push(x.first);
}
}
}
for(int i = 1; i < n; i++){
cout << tavok[i] << "\n";
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1812 KiB | ||||
2 | Wrong answer | 9ms | 2892 KiB | ||||
subtask2 | 0/8 | ||||||
3 | Accepted | 6ms | 2828 KiB | ||||
4 | Wrong answer | 6ms | 3068 KiB | ||||
5 | Wrong answer | 7ms | 3320 KiB | ||||
6 | Wrong answer | 7ms | 3628 KiB | ||||
7 | Wrong answer | 7ms | 3860 KiB | ||||
subtask3 | 0/15 | ||||||
8 | Wrong answer | 3ms | 3724 KiB | ||||
9 | Accepted | 3ms | 3792 KiB | ||||
10 | Accepted | 3ms | 3900 KiB | ||||
11 | Wrong answer | 3ms | 3868 KiB | ||||
12 | Wrong answer | 2ms | 3868 KiB | ||||
13 | Wrong answer | 2ms | 3876 KiB | ||||
14 | Wrong answer | 2ms | 3880 KiB | ||||
15 | Wrong answer | 3ms | 3912 KiB | ||||
16 | Accepted | 3ms | 3904 KiB | ||||
17 | Accepted | 3ms | 4032 KiB | ||||
18 | Wrong answer | 3ms | 4100 KiB | ||||
subtask4 | 0/34 | ||||||
19 | Accepted | 8ms | 4816 KiB | ||||
20 | Wrong answer | 8ms | 5036 KiB | ||||
21 | Wrong answer | 8ms | 4952 KiB | ||||
22 | Accepted | 8ms | 5032 KiB | ||||
23 | Accepted | 8ms | 5208 KiB | ||||
24 | Wrong answer | 8ms | 5268 KiB | ||||
25 | Accepted | 8ms | 5220 KiB | ||||
26 | Accepted | 8ms | 5312 KiB | ||||
27 | Wrong answer | 8ms | 5156 KiB | ||||
28 | Wrong answer | 6ms | 5048 KiB | ||||
29 | Wrong answer | 6ms | 5088 KiB | ||||
30 | Wrong answer | 6ms | 5112 KiB | ||||
31 | Wrong answer | 6ms | 5156 KiB | ||||
32 | Wrong answer | 8ms | 5664 KiB | ||||
33 | Wrong answer | 8ms | 5748 KiB | ||||
subtask5 | 0/21 | ||||||
34 | Wrong answer | 4ms | 5276 KiB | ||||
35 | Wrong answer | 4ms | 5572 KiB | ||||
36 | Wrong answer | 4ms | 5704 KiB | ||||
37 | Wrong answer | 4ms | 5732 KiB | ||||
38 | Wrong answer | 4ms | 5772 KiB | ||||
39 | Wrong answer | 4ms | 5924 KiB | ||||
40 | Wrong answer | 4ms | 5816 KiB | ||||
41 | Wrong answer | 4ms | 5996 KiB | ||||
42 | Wrong answer | 3ms | 6020 KiB | ||||
43 | Wrong answer | 3ms | 6032 KiB | ||||
44 | Wrong answer | 3ms | 6092 KiB | ||||
45 | Wrong answer | 3ms | 6364 KiB | ||||
46 | Wrong answer | 3ms | 6196 KiB | ||||
47 | Wrong answer | 3ms | 6204 KiB | ||||
48 | Wrong answer | 4ms | 6236 KiB | ||||
49 | Wrong answer | 4ms | 6304 KiB | ||||
subtask6 | 0/22 | ||||||
50 | Wrong answer | 9ms | 6988 KiB | ||||
51 | Wrong answer | 10ms | 7168 KiB | ||||
52 | Wrong answer | 10ms | 7280 KiB | ||||
53 | Wrong answer | 10ms | 7364 KiB | ||||
54 | Wrong answer | 10ms | 7512 KiB | ||||
55 | Wrong answer | 9ms | 7576 KiB | ||||
56 | Wrong answer | 8ms | 7464 KiB | ||||
57 | Wrong answer | 8ms | 7820 KiB | ||||
58 | Wrong answer | 4ms | 7420 KiB | ||||
59 | Wrong answer | 7ms | 7856 KiB | ||||
60 | Wrong answer | 7ms | 8004 KiB | ||||
61 | Wrong answer | 7ms | 8060 KiB | ||||
62 | Wrong answer | 7ms | 8228 KiB | ||||
63 | Wrong answer | 6ms | 8120 KiB | ||||
64 | Wrong answer | 10ms | 8532 KiB | ||||
65 | Wrong answer | 9ms | 8744 KiB | ||||
66 | Wrong answer | 9ms | 8828 KiB |