| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1292713 | ChuanChen | 기지국 (IOI20_stations) | C++20 | 399 ms | 548 KiB |
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3+3;
vector<int> adj[MAXN];
int tin[MAXN], tout[MAXN], tempo;
bool used[MAXN];
void dfs(int no){
used[no] = true;
tin[no] = ++tempo;
for(int v : adj[no]) if(!used[v]){
dfs(v);
}
tout[no] = tempo;
}
inline int pre(int a);
inline int pos(int a);
vector<int> label(int n, int k, vector<int> u, vector<int> v){
for(int i = 0; i < n; i++){
used[i] = false;
tin[i] = tout[i] = 0;
adj[i].clear();
}
tempo = 0;
for (int i = 0; i < (int)u.size(); i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0);
vector<int> labels(n);
for (int i = 0; i < n; i++) {
// labels[i] = 0;
labels[i] = tin[i]*1000+tout[i];
// cerr << "i: " << i << " " << pre(labels[i]) << ' ' << pos(labels[i]) << endl;
}
return labels;
}
inline int pre(int a){
return a/1000;
}
inline int pos(int a){
return a%1000;
}
int find_next_station(int s, int t, vector<int> c) {
if(pre(s) <= pre(t) && pos(t) <= pos(s)){ //t eh filho
for(int l : c){
if(pre(l) <= pre(s) && pos(s) <= pos(l)) continue;
if(pre(l) <= pre(t) && pos(t) <= pos(l)) return l;
}
}
for(int l : c){
if(pre(l) <= pre(s) && pos(s) <= pos(l)) return l;
}
// return c[0];
}
컴파일 시 표준 에러 (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... | ||||
