| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 745728 | yeyso | 꿈 (IOI13_dreaming) | C++14 | 149 ms | 40692 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj; vector<vector<int>> dmj; vector<int> dist; vector<int> dist2; vector<set<pair<int, int>>> components; vector<set<pair<int, int>>> components2;
void dfs(int node, int parent, int distance, int component, int mode){
if(mode == 0) components[component].insert({distance, node});
if(mode == 1) components2[component].insert({distance, node});
dist[node] = distance;
for(int i = 0; i < adj[node].size(); i ++){
if(adj[node][i] != parent){
dfs(adj[node][i], node, distance + dmj[node][i], component, mode);
}
}
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
vector<vector<int>> adj0(N, vector<int>()); vector<vector<int>> dmj0(N, vector<int>());
for(int i = 0; i < M; i ++){
adj0[A[i]].push_back(B[i]); adj0[B[i]].push_back(A[i]);
dmj0[A[i]].push_back(T[i]); dmj0[B[i]].push_back(T[i]);
}
vector<int> dist0(N, INT_MAX / 2);
adj = adj0; dmj = dmj0; dist = dist0; dist2 = dist0;
int component_ = 0;
for(int i = 0; i < N; i ++){
if(dist[i] >= INT_MAX / 2){
components.push_back({}); components2.push_back({});
dist[i] = 0;
dfs(i, -1, 0, component_, 0);
component_ += 1;
}
}
for(int i = 0; i < components.size(); i ++){
//cout << (*(--components[i].end())).second << " ";
dfs((*(--components[i].end())).second, -1, 0, i, 1);
} //cout << "\n";
int furtherest = 0; int mid = 0; int mid2 = 0; int split = 0;
set<pair<int, int>> components3;
for(int i = 0; i < components2.size(); i ++){
furtherest = (*(--components2[i].end())).first;
mid = (*(components2[i].upper_bound({furtherest / 2, 0}))).first;
mid2 = (*(--components2[i].upper_bound({furtherest / 2, 0}))).first;
if(abs(furtherest - mid) > abs(furtherest - mid2)){ split = mid2;
} else { split = mid; }
if(split > furtherest / 2) components3.insert({split, furtherest - split});
else components3.insert({furtherest - split, split});
}
int maxacross = (*(--components3.end())).first + (*(----components3.end())).first + L;
int maxwithin = (*(--components3.end())).first + (*(--components3.end())).second;
return max(maxacross, maxwithin);
}
/*
g++ -DEVAL -static -O2 -o dreaming grader.cpp dreaming.cpp
12 8 2
0 8 4
8 2 2
2 7 4
5 11 3
5 1 7
1 3 1
1 9 5
10 6 3
*/컴파일 시 표준 에러 (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... | ||||
