Submission #1260130
Source Code Expand
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class DIJ{
public:
struct edge{
int to,cost;
};
vector<vector<edge> >G;
int n,L;
vvi d;//distance
DIJ(int size,int l){
n=size;
L=l;
G=vector<vector<edge> >(n);
}
void add_edge(int a,int b,int c){
edge e={b,c},ee={a,c};
G[a].pb(e);
G[b].pb(ee);
}
void dij(int s){
d=vvi(n,vi(L,inf));
d[s][0]=0;//now time%28 ->time
priority_queue<pip>q;
q.push(pip(0,pii(s,0)));//time now time%28
while(!q.empty()){
pip p=q.top();
q.pop();
int pos=p.second.first,cost=-p.first,nu=p.second.second;
if(cost>d[pos][cost%28])continue;
rep(i,G[pos].size()){
edge e=G[pos][i];
int to=e.to;
int nowcost=cost+e.cost;
if(nowcost<d[to][nowcost%28]){
d[to][nowcost%28]=nowcost;
q.push(pip(-nowcost,pii(to,0)));
}
}
}
}
};
int main(){
int n,m;
cin>>n>>m;
DIJ dij(n,28);
rep(i,m){
int a,b,c;
cin>>a>>b>>c;
dij.add_edge(a,b,c);
}
dij.dij(0);
int mi=inf;
rep(i,28)if(i%4==0||i%7==0)mi=min(mi,dij.d[n-1][i]);
cout<<mi<<endl;
}
Submission Info
Submission Time |
|
Task |
E - 会場への道 |
User |
ixmel_rd |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2051 Byte |
Status |
WA |
Exec Time |
20 ms |
Memory |
1532 KB |
Judge Result
Set Name |
sub1 |
sub2 |
Score / Max Score |
0 / 30 |
0 / 70 |
Status |
|
|
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 |
384 KB |
sub1/input_21.txt |
AC |
3 ms |
384 KB |
sub1/input_22.txt |
AC |
3 ms |
384 KB |
sub1/input_23.txt |
AC |
3 ms |
384 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 |
WA |
1 ms |
256 KB |
sub1/input_7.txt |
AC |
1 ms |
256 KB |
sub1/input_8.txt |
WA |
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 |
3 ms |
512 KB |
sub2/input_11.txt |
AC |
19 ms |
1532 KB |
sub2/input_12.txt |
AC |
19 ms |
1532 KB |
sub2/input_13.txt |
AC |
3 ms |
384 KB |
sub2/input_14.txt |
AC |
14 ms |
960 KB |
sub2/input_15.txt |
AC |
19 ms |
1532 KB |
sub2/input_16.txt |
AC |
20 ms |
1532 KB |
sub2/input_17.txt |
AC |
19 ms |
1532 KB |
sub2/input_18.txt |
AC |
19 ms |
1532 KB |
sub2/input_19.txt |
AC |
18 ms |
1216 KB |
sub2/input_2.txt |
AC |
1 ms |
256 KB |
sub2/input_20.txt |
AC |
3 ms |
384 KB |
sub2/input_21.txt |
AC |
3 ms |
384 KB |
sub2/input_22.txt |
AC |
3 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 |
3 ms |
512 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 |
WA |
1 ms |
256 KB |
sub2/input_7.txt |
AC |
1 ms |
256 KB |
sub2/input_8.txt |
WA |
1 ms |
256 KB |
sub2/input_9.txt |
AC |
1 ms |
256 KB |