Submission #1175720


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> P;

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

struct Edge {
	int to, lastpos;
	ll cost, lastcost;
	
	
	Edge(int to, ll cost, int lastpos, ll lastcost)
	 : to(to), cost(cost), lastpos(lastpos), lastcost(lastcost) {}
};

int n, m;
int st, ed;
vector<Edge> g[26000];
int s[26000], w[26000];
ll sum[26000], d[26000];

int main() {
	cin >> n >> m >> st >> ed;
	REP(i, m) {
		int l;
		scanf("%d", &l);
		
		REP(j, l) scanf("%d", s + j);
		REP(j, l - 1) scanf("%d", w + j);
		
		sum[0] = 0;
		REP(j, l) sum[j + 1] = sum[j] + w[j];
		
		REP(j, l - 1) g[s[j]].push_back(Edge(s[j + 1], w[j], s[l - 1], sum[l - 1] - sum[j]));
		for (int j = l - 1; j > 0; j--) g[s[j]].push_back(Edge(s[j - 1], w[j - 1], s[0], sum[j] - sum[0]));
	}
	
	fill(d, d + n, INFL);
	
	priority_queue<P, vector<P>, greater<P> > pq;
	pq.push(P(1, pll(0, st)));
	
	while (!pq.empty()) {
		P now = pq.top(); pq.pop();
		
		ll over = -now.first;
		ll cost = now.second.first;
		int pos = now.second.second;
		
		if (over != -1 && !chmin(d[pos], cost + over * 2)) continue;
		
		REP(i, g[pos].size()) {
			Edge& e = g[pos][i];
			
			pq.push(P(- max(over, e.lastcost - e.cost), pll(cost + e.cost, e.to)));
			pq.push(P(0, pll(cost + e.lastcost, e.lastpos)));
		}
	}
	
	cout << d[ed] << endl;
	
	return 0;
}

Submission Info

Submission Time
Task C - メンテナンス明け
User tkmst201
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1876 Byte
Status WA
Exec Time 2656 ms
Memory 399192 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:41:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &l);
                  ^
./Main.cpp:43:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(j, l) scanf("%d", s + j);
                               ^
./Main.cpp:44:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(j, l - 1) scanf("%d", w + j);
                                   ^

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 0 / 50 0 / 50
Status
AC × 22
WA × 30
AC × 1
TLE × 5
Set Name Test Cases
Subtask1 small/00_sample00, small/00_sample01, small/00_sample02, small/10_small-0000, small/10_small-0001, small/10_small-0002, small/10_small-0003, small/10_small-0004, small/10_small-0005, small/10_small-0006, small/10_small-0007, small/10_small-0008, small/10_small-0009, small/10_small-0010, small/10_small-0011, small/10_small-0012, small/10_small-0013, small/10_small-0014, small/10_small-0015, small/10_small-0016, small/10_small-0017, small/10_small-0018, small/10_small-0019, small/30_max_small, small/40_simple_0000, small/40_simple_0001, small/40_simple_0002, small/40_simple_0003, small/40_simple_0004, small/40_simple_0005, small/40_simple_0006, small/40_simple_0007, small/40_simple_0008, small/40_simple_0009, small/40_simple_0010, small/40_simple_0011, small/40_simple_0012, small/40_simple_0013, small/40_simple_0014, small/40_simple_0015, small/40_simple_0016, small/40_simple_0017, small/40_simple_0018, small/40_simple_0019, small/90_dijkstra_killer_00, small/90_dijkstra_killer_01, small/91_tayama_killer_00, small/91_tayama_killer_01, small/91_tayama_killer_02, small/91_tayama_killer_03, small/91_tayama_killer_04, small/91_tayama_killer_05
Subtask2 large/20_large-00, large/20_large-01, large/20_large-02, large/20_large-03, large/20_large-04, large/31_max_large
Case Name Status Exec Time Memory
large/20_large-00 TLE 2656 ms 397528 KB
large/20_large-01 TLE 2656 ms 398552 KB
large/20_large-02 TLE 2656 ms 399192 KB
large/20_large-03 TLE 2656 ms 202332 KB
large/20_large-04 TLE 2656 ms 201052 KB
large/31_max_large AC 21 ms 4728 KB
small/00_sample00 AC 1 ms 896 KB
small/00_sample01 AC 1 ms 896 KB
small/00_sample02 AC 1 ms 896 KB
small/10_small-0000 WA 9 ms 1788 KB
small/10_small-0001 WA 11 ms 1788 KB
small/10_small-0002 WA 8 ms 1792 KB
small/10_small-0003 WA 10 ms 1788 KB
small/10_small-0004 WA 11 ms 1788 KB
small/10_small-0005 WA 12 ms 1788 KB
small/10_small-0006 WA 9 ms 1788 KB
small/10_small-0007 WA 12 ms 1788 KB
small/10_small-0008 WA 10 ms 1792 KB
small/10_small-0009 WA 6 ms 1472 KB
small/10_small-0010 WA 8 ms 1792 KB
small/10_small-0011 WA 11 ms 1788 KB
small/10_small-0012 WA 8 ms 1788 KB
small/10_small-0013 WA 9 ms 1788 KB
small/10_small-0014 WA 10 ms 1788 KB
small/10_small-0015 WA 11 ms 1788 KB
small/10_small-0016 WA 13 ms 2556 KB
small/10_small-0017 WA 8 ms 1788 KB
small/10_small-0018 WA 11 ms 1788 KB
small/10_small-0019 WA 12 ms 1792 KB
small/30_max_small AC 2 ms 896 KB
small/40_simple_0000 WA 1 ms 896 KB
small/40_simple_0001 WA 1 ms 896 KB
small/40_simple_0002 AC 1 ms 896 KB
small/40_simple_0003 AC 1 ms 896 KB
small/40_simple_0004 AC 1 ms 896 KB
small/40_simple_0005 AC 1 ms 896 KB
small/40_simple_0006 WA 1 ms 896 KB
small/40_simple_0007 AC 1 ms 896 KB
small/40_simple_0008 AC 1 ms 896 KB
small/40_simple_0009 AC 1 ms 896 KB
small/40_simple_0010 AC 1 ms 896 KB
small/40_simple_0011 AC 1 ms 896 KB
small/40_simple_0012 AC 1 ms 896 KB
small/40_simple_0013 WA 1 ms 896 KB
small/40_simple_0014 AC 1 ms 896 KB
small/40_simple_0015 AC 1 ms 896 KB
small/40_simple_0016 AC 1 ms 896 KB
small/40_simple_0017 AC 1 ms 896 KB
small/40_simple_0018 WA 1 ms 896 KB
small/40_simple_0019 WA 1 ms 896 KB
small/90_dijkstra_killer_00 WA 2 ms 896 KB
small/90_dijkstra_killer_01 WA 1 ms 896 KB
small/91_tayama_killer_00 WA 1 ms 896 KB
small/91_tayama_killer_01 AC 1 ms 896 KB
small/91_tayama_killer_02 AC 1 ms 896 KB
small/91_tayama_killer_03 WA 2 ms 896 KB
small/91_tayama_killer_04 AC 1 ms 896 KB
small/91_tayama_killer_05 AC 2 ms 896 KB