답안 #468154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
468154 2021-08-26T23:11:28 Z SirCovidThe19th 꿈 (IOI13_dreaming) C++17
18 / 100
50 ms 12484 KB
#include <bits/stdc++.h>
#include "dreaming.h"
using namespace std; 

#define pii pair<int, int>
#define f first
#define s second

const int mx = 1e5 + 5, inf = 1e9;

vector<pair<int, int>> adj[mx]; pii in[mx]; bool vis[mx];

void comb(pii &p, int x){
	if (x > p.f) p.s = p.f, p.f = x;
	else if (x > p.s) p.s = x;
}
void dfs1(int i, int p){
    vis[i] = 1;
    for (auto [x, w] : adj[i]) if (x != p){
        dfs1(x, i); 
		comb(in[i], in[x].f + w);
    }
}
void dfs2(int i, int p, int pout, int &mnD){
    mnD = min(mnD, max(pout, in[i].f));
    for (auto [x, w] : adj[i]) if (x != p){
        int sib = (in[i].f == in[x].f + w) ? in[i].s : in[i].f;
        int out = max(sib, pout) + w;
        dfs2(x, i, out, mnD);
    }
}
int travelTime(int n, int m, int l, int A[], int B[], int T[]){
    for (int i = 0; i < m; i++){
        adj[A[i]].push_back({B[i], T[i]});
        adj[B[i]].push_back({A[i], T[i]});
    }
    int w[3] = {-l, -l, -l};
    for (int i = 0; i < n; i++) if (!vis[i]){
        int mnD = 1e9; dfs1(i, 0); dfs2(i, 0, 0, mnD);
		if (mnD > w[0]) w[2] = w[1], w[1] = w[0], w[0] = mnD;
		else if (mnD > w[1]) w[2] = w[1], w[1] = mnD;
		else if (mnD > w[2]) w[2] = mnD;
    }
	return max(w[0] + w[1] + l, w[1] + w[2] + 2 * l);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 12484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 12484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 6228 KB Output is correct
2 Correct 20 ms 6240 KB Output is correct
3 Correct 19 ms 6220 KB Output is correct
4 Correct 32 ms 6200 KB Output is correct
5 Correct 34 ms 6116 KB Output is correct
6 Correct 21 ms 6348 KB Output is correct
7 Correct 20 ms 6376 KB Output is correct
8 Correct 19 ms 6120 KB Output is correct
9 Correct 19 ms 6124 KB Output is correct
10 Correct 26 ms 6348 KB Output is correct
11 Correct 2 ms 2656 KB Output is correct
12 Correct 3 ms 3296 KB Output is correct
13 Correct 4 ms 3404 KB Output is correct
14 Correct 4 ms 3276 KB Output is correct
15 Correct 3 ms 3276 KB Output is correct
16 Correct 3 ms 3148 KB Output is correct
17 Correct 3 ms 2892 KB Output is correct
18 Correct 5 ms 3404 KB Output is correct
19 Correct 4 ms 3148 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 4 ms 3148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 12484 KB Output isn't correct
2 Halted 0 ms 0 KB -