# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
433399 | Enkognit | 기지국 (IOI20_stations) | C++14 | 884 ms | 864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "stations.h"
#include <vector>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
vector<int> c[1005];
vector<int> vv;
ll T;
void dfs(int h,int k, int p)
{
if (k%2==0) vv[h]=T++;
for (int i = 0; i < c[h].size(); i++)
if (c[h][i]!=p)
{
dfs(c[h][i], k+1, h);
}
if (k%2) vv[h]=T++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<int> f;
vv.resize(n, 0);
T=0;
vector<pair<ll, ll> > ed;
for (int i = 0; i < u.size(); i++)
{
ed.pb(mp(u[i], v[i]));
c[u[i]].pb(v[i]);
c[v[i]].pb(u[i]);
}
dfs(0, 0, 0);
f.resize(n, 0);
f=vv;
vv.clear();
//for (int i = 0; i < n; i++) cout << vv[i] << "\n";
//for (int i = 0; i < ed.size(); i++)
// cout << vv[ed[i].fi] << " " << vv[ed[i].se] << "\n";
//cout << "---\n";
for (int i = 0; i < n; i++) c[i].clear();
return f;
}
int find_next_station(int s, int t, std::vector<int> c)
{
/*cout << c.size() << " : ";
for (int i = 0; i < c.size(); i++)
cout << c[i] << " ";
cout << "\n";
cout << s << "\n";*/
if (s==t) return s;
if (c.size()==1) return c[0];
//cout << "\n";
//assert((int)c.size()==0);
if (s<c[0])
{
if (!(t>s && t<c.back())) return c.back();
ll lst=s;
for (int i = 0; i < c.size()-1; i++)
if (t>lst && c[i]>=t) return c[i]; else lst=c[i];
return c.back();
}else
{
if (!(t<s && t>c[0])) return c[0];
ll lst=s;
for (int i = c.size()-1; i > 0; i--)
if (t<lst && t>=c[i]) return c[i]; else lst=c[i];
return c[0];
}
assert(0);
return 1;
}
/*
1
5 10
0 1
1 2
1 3
2 4
2
2 0 2
1 3 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... |