# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
577503 | definitelynotmee | Simurgh (IOI17_simurgh) | C++98 | 117 ms | 3500 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "simurgh.h"
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
using matrix = vector<vector<T>>;
const int INF = 1e7;
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
int m = u.size();
matrix<pii> g(n);
for(int i = 0; i < m; i++){
g[u[i]].push_back({v[i],i});
g[v[i]].push_back({u[i],i});
}
vector<int> royal, dfstree;
dfstree.reserve(n);
royal.reserve(n);
vector<int> check(n), tin(n);
int timer = -1;
auto gettree =[&](int id, auto dfs)->void{
check[id] = 1;
tin[id] = ++timer;
for(auto [viz,edge] : g[id]){
if(!check[viz]){
dfstree.push_back(edge);
dfs(viz,dfs);
}
}
};
gettree(0,gettree);
// for(int i : dfstree){
// cout << "->" << u[i] << ' ' << v[i] << '\n';
// }
fill(all(check),0);
auto test =[&](int id, int remove){
vector<int> query = dfstree;
for(int& i : query){
if(i == remove){
i = id;
break;
}
}
return count_common_roads(query);
};
auto dfs =[&](int id, int last, auto dfs)->pii{
check[id] = 1;
pii back = {INF,0};
for(auto [viz,edge] : g[id]){
if(!check[viz]){
back = min(back,dfs(viz,edge,dfs));
}
}
if(last == -1)
return {0,0};
int resp = back.ff >= tin[id] ? 0 : test(back.ss,last);
vector<int> child(g[id].size());
for(int i = 0; i < g[id].size(); i++){
int viz = g[id][i].ff, edge = g[id][i].ss;
if(tin[viz] > tin[id])
continue;
child[i] = test(edge,last);
resp = max(resp,child[i]);
}
for(int i = 0; i < g[id].size(); i++){
int viz = g[id][i].ff, edge = g[id][i].ss;
if(tin[viz] > tin[id])
continue;
if(child[i] == resp){
back = min(back,{tin[viz],edge});
royal.push_back(edge);
}
}
return back;
};
dfs(0,-1,dfs);
return royal;
}
컴파일 시 표준 에러 (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... |