# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
155843 | TAISA_ | Dreaming (IOI13_dreaming) | C++14 | 56 ms | 8276 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dreaming.h"
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (1 << 30) - 1;
const ll LINF = (1LL << 60) - 1LL;
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
if (M == N - 1) {
return 0;
}
vector<vector<P>> G(N);
vector<int> vis(N);
for (int i = 0; i < M; i++) {
G[A[i]].push_back(P(B[i], T[i]));
G[B[i]].push_back(P(A[i], T[i]));
}
vector<ll> s;
for (int i = 0; i < N; i++) {
if (!vis[i] && G[i].size() == 1) {
vis[i] = 1;
vector<ll> v;
int t = G[i][0].first, p = i;
v.push_back(G[i][0].second);
while (G[t].size() > 1) {
vis[t] = 1;
if (G[t][0].first == p) {
v.push_back(G[t][1].second);
t = G[t][1].first;
} else {
v.push_back(G[t][0].second);
t = G[t][0].first;
}
}
vis[t] = 1;
vector<ll> sum(v.size() + 1);
for (int j = 0; j < v.size(); j++) {
sum[j + 1] = sum[j] + v[j];
}
ll mi = LINF;
for (int j = 0; j <= v.size(); j++) {
mi = min(mi, max(sum[j], sum[v.size()] - sum[j]));
}
s.push_back(mi);
}
}
sort(all(s));
reverse(all(s));
ll ans = 0;
if (s.size() > 1) {
ans = max(ans, s[0] + s[1] + L);
}
if (s.size() > 2) {
ans = max(ans, s[1] + s[2] + 2LL * L);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |