Submission #103113

# Submission time Handle Problem Language Result Execution time Memory
103113 2019-03-29T04:45:41 Z dimash241 Dreaming (IOI13_dreaming) C++17
0 / 100
1000 ms 18680 KB
#include "dreaming.h"
#include <bits/stdc++.h>
 
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red
 
using namespace std;
 
const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;
 
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int dp[N];
vector < pair < int, int > > g[N];
 
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	n = N, m = M, k = L;
	for (int i = 1; i <= m; i ++) {
		int l, r, x;
		l = A[i - 1], r = B[i - 1], x = T[i - 1]; 
		g[l].pb(mp(r, x));
		g[r].pb(mp(l, x));
	}
	if (n - 2 == m) {
		int ans = INT_MAX;
		for (int i = 1; i <= n; i ++) {
			for (int j = i + 1; j <= n; j ++) {
				g[i].pb(mp(j, k));
				g[j].pb(mp(i, k));
				for (int w = 1; w <= n; w ++)
					dp[w] = INT_MAX;
				priority_queue < pair < ll, int > > s;
				s.push(mp(0ll, 1));
				dp[1] = 0;
				while (s.size()) {
					int v = s.top().S;
					s.pop();
 
					for (auto to : g[v]) {
						if (dp[to.F] > dp[v] + to.S) {
							dp[to.F] = dp[v] + to.S;
							s.push(mp(dp[to.F], to.F));
						}
					}
				}
				int st = max_element(dp + 1, dp + n + 1) - dp;
				for (int w = 1; w <= n; w ++)
					dp[w] = INT_MAX;
				dp[st] = 0;
				s.push(mp(0ll, st));
				while (s.size()) {
					int v = s.top().S;
					s.pop();
 
					for (auto to : g[v]) {
						if (dp[to.F] > dp[v] + to.S) {
							dp[to.F] = dp[v] + to.S;
							s.push(mp(dp[to.F], to.F));
						}
					}
				}
				
				ans = min(ans, *max_element(dp + 1, dp + n + 1));
				g[i].pop_back();
				g[j].pop_back();
			}
		}
		return (int)ans;
	}
    return 18;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 18680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 18680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 18680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 16752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 18680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 18680 KB Time limit exceeded
2 Halted 0 ms 0 KB -