| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 348075 | blue | Stations (IOI20_stations) | C++17 | 5 ms | 620 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <iostream>
#include <vector>
using namespace std;
vector<int> edge[1000];
vector<int> visit(1000, 0);
vector<int> L;
int dfs(int u, int a, bool flag) //vertex, minimum label, left/right? return largest unused label
{
visit[u] = 1;
if(flag == 0)
{
L[u] = a;
a++;
}
for(int v: edge[u])
{
if(visit[v]) continue;
a = dfs(v, a, !flag);
}
if(flag == 1)
{
L[u] = a;
a++;
}
return a;
}
/*
0
/ | \
1 2 3
/ \ \
4 5 6
*/
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
for(int j = 0; j < n-1; j++)
{
edge[u[j]].push_back(v[j]);
edge[v[j]].push_back(u[j]);
}
L = vector<int>(n, -1);
dfs(0, 0, 0);
return L;
}
int find_next_station(int s, int t, vector<int> c)
{
if(s < c[0]) // s is left label
{
if(t < s) return c.back();
for(int i = 0; i < c.size(); i++) if(t <= c[i]) return c[i];
}
else // s is right label
{
if(t > s) return c[0];
for(int i = c.size()-1; i >= 0; i--) if(t >= c[i]) return c[i];
}
}컴파일 시 표준 에러 (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... | ||||
