Submission #1200650
Source Code Expand
#include<iostream> #include<cstdio> #include<string> #include<algorithm> #include<vector> #include<queue> #include<functional> #include<map> #include<cstring> #include<unordered_map> #include<set> #include<string.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; }
Submission Info
Submission Time | |
---|---|
Task | E - 会場への道 |
User | naoki2016 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1261 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:41:12: error: ‘LLONG_MAX’ was not declared in this scope int ans = LLONG_MAX; ^ ./Main.cpp:20: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:22: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); ^