#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>//cost to
using namespace std;
int mincost[1000][28];//時間を28で割った余り
vector<P>rinsetu[1000];
signed main() {
int a, b; scanf("%lld%lld", &a, &b);
for (int c = 0; c < b; c++) {
int d, e, f; scanf("%lld%lld%lld", &d, &e, &f);
rinsetu[d].push_back(P(f, e));
rinsetu[e].push_back(P(f, d));
}
memset(mincost, 0x3f, sizeof(mincost));
mincost[0][0] = 0;
priority_queue<P, vector<P>, greater<P>>Q;
Q.push({ 0,0 });
while (Q.size()) {
P t = Q.top(); Q.pop();
if (mincost[t.second][t.first % 28] < t.first)continue;
if (t.second == a - 1)continue;
for (P i : rinsetu[t.second]) {
if (mincost[i.second][(t.first + i.first) % 28] > t.first + i.first) {
mincost[i.second][(t.first + i.first) % 28] = t.first + i.first;
Q.push({ t.first + i.first ,i.second });
}
}
}
int ans = LLONG_MAX;
for (int i = 0; i < 28; i++) {
if (i % 4 == 0 || i % 7 == 0)ans = min(ans, mincost[a - 1][i]);
}
cout << ans << endl;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:9:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int a, b; scanf("%lld%lld", &a, &b);
^
./Main.cpp:11:49: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int d, e, f; scanf("%lld%lld%lld", &d, &e, &f);
^