Submission #4243058


Source Code Expand

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<vector<pair<int, long long> > > edge(n);
  REP(i, m) {
    int f, t; cin >> f >> t;
    long long c; cin >> c;
    edge[f].emplace_back(t, c);
    edge[t].emplace_back(f, c);
  }
  vector<vector<long long> > dist(n, vector<long long>(28, LINF));
  dist[0][0] = 0;
  priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > que;
  que.emplace(0, 0);
  while (!que.empty()) {
    auto au = que.top(); que.pop();
    long long cost = au.first;
    int ver = au.second;
    if (dist[ver][cost%28] < cost || ver == n-1) continue;
    for (auto e : edge[ver]) {
      long long nx_cost = dist[ver][cost%28] + e.second;
      if (nx_cost < dist[e.first][nx_cost%28]) {
        dist[e.first][nx_cost%28] = nx_cost;
        que.emplace(nx_cost, e.first);
      }
    }
  }
  cout << min({dist[n-1][0], dist[n-1][4], dist[n-1][7], dist[n-1][8], dist[n-1][12], dist[n-1][14], dist[n-1][16], dist[n-1][20], dist[n-1][21], dist[n-1][24]}) << '\n';
  return 0;
}

Submission Info

Submission Time
Task E - 会場への道
User emthrm
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1823 Byte
Status AC
Exec Time 16 ms
Memory 2172 KB

Judge Result

Set Name sub1 sub2
Score / Max Score 30 / 30 70 / 70
Status
AC × 15
AC × 26
Set Name Test Cases
sub1 sub1/input_0.txt, sub1/input_1.txt, sub1/input_2.txt, sub1/input_20.txt, sub1/input_21.txt, sub1/input_22.txt, sub1/input_23.txt, sub1/input_24.txt, sub1/input_3.txt, sub1/input_4.txt, sub1/input_5.txt, sub1/input_6.txt, sub1/input_7.txt, sub1/input_8.txt, sub1/input_9.txt
sub2 sub2/input_0.txt, sub2/input_1.txt, sub2/input_10.txt, sub2/input_11.txt, sub2/input_12.txt, sub2/input_13.txt, sub2/input_14.txt, sub2/input_15.txt, sub2/input_16.txt, sub2/input_17.txt, sub2/input_18.txt, sub2/input_19.txt, sub2/input_2.txt, sub2/input_20.txt, sub2/input_21.txt, sub2/input_22.txt, sub2/input_23.txt, sub2/input_24.txt, sub2/input_25.txt, sub2/input_3.txt, sub2/input_4.txt, sub2/input_5.txt, sub2/input_6.txt, sub2/input_7.txt, sub2/input_8.txt, sub2/input_9.txt
Case Name Status Exec Time Memory
sub1/input_0.txt AC 1 ms 256 KB
sub1/input_1.txt AC 1 ms 256 KB
sub1/input_2.txt AC 1 ms 256 KB
sub1/input_20.txt AC 3 ms 512 KB
sub1/input_21.txt AC 3 ms 384 KB
sub1/input_22.txt AC 2 ms 384 KB
sub1/input_23.txt AC 1 ms 256 KB
sub1/input_24.txt AC 2 ms 384 KB
sub1/input_3.txt AC 1 ms 256 KB
sub1/input_4.txt AC 1 ms 256 KB
sub1/input_5.txt AC 1 ms 256 KB
sub1/input_6.txt AC 1 ms 256 KB
sub1/input_7.txt AC 1 ms 256 KB
sub1/input_8.txt AC 1 ms 256 KB
sub1/input_9.txt AC 1 ms 256 KB
sub2/input_0.txt AC 1 ms 256 KB
sub2/input_1.txt AC 1 ms 256 KB
sub2/input_10.txt AC 2 ms 640 KB
sub2/input_11.txt AC 14 ms 2172 KB
sub2/input_12.txt AC 14 ms 2172 KB
sub2/input_13.txt AC 2 ms 640 KB
sub2/input_14.txt AC 9 ms 1408 KB
sub2/input_15.txt AC 14 ms 2172 KB
sub2/input_16.txt AC 16 ms 2172 KB
sub2/input_17.txt AC 15 ms 2172 KB
sub2/input_18.txt AC 15 ms 2172 KB
sub2/input_19.txt AC 13 ms 1792 KB
sub2/input_2.txt AC 1 ms 256 KB
sub2/input_20.txt AC 3 ms 512 KB
sub2/input_21.txt AC 3 ms 384 KB
sub2/input_22.txt AC 2 ms 384 KB
sub2/input_23.txt AC 1 ms 256 KB
sub2/input_24.txt AC 2 ms 384 KB
sub2/input_25.txt AC 2 ms 640 KB
sub2/input_3.txt AC 1 ms 256 KB
sub2/input_4.txt AC 1 ms 256 KB
sub2/input_5.txt AC 1 ms 256 KB
sub2/input_6.txt AC 1 ms 256 KB
sub2/input_7.txt AC 1 ms 256 KB
sub2/input_8.txt AC 1 ms 256 KB
sub2/input_9.txt AC 1 ms 256 KB