# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
828487 | tolbi | Simurgh (IOI17_simurgh) | C++17 | 131 ms | 8360 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define coutara(x,y) for (auto &it : x) cout<<it<<" ";cout<<y<<endl;
#include "simurgh.h"
int ask(set<int> &st){
vector<int> askarr;
auto it = st.begin();
while (it!=st.end()){
askarr.push_back(*it);
it++;
}
int ans = count_common_roads(askarr);
//coutara(askarr,ans);
return ans;
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
vector<vector<int>> arr(n);
int m = u.size();
map<pair<int,int>,int> mp;
for (int i = 0; i < m; i++){
arr[u[i]].push_back(v[i]);
arr[v[i]].push_back(u[i]);
mp[{u[i],v[i]}]=i;
}
auto getindex = [&](pair<int,int> pr){
if (mp.count(pr)) return mp[pr];
swap(pr.first,pr.second);
return mp[pr];
};
vector<int> par(n);
vector<bool> vis(n,false);
set<int> askarr;
vector<int> dept(n);
vector<int> origset;
auto dfs = [&](int node, auto dfs)->void{
vis[node]=true;
for (int i = 0; i < arr[node].size(); i++){
if (vis[arr[node][i]]) continue;
par[arr[node][i]]=node;
dept[arr[node][i]]=dept[node]+1;
askarr.insert(getindex({node,arr[node][i]}));
origset.push_back(getindex({node,arr[node][i]}));
dfs(arr[node][i],dfs);
}
};
dept[0]=0;
dfs(0,dfs);
int origans = ask(askarr);
vector<int> hueh(m,1);
for (int i = 0; i < m; i++){
if (askarr.find(i)!=askarr.end()) continue;
int a = u[i];
int b = v[i];
vector<int> yep;
vector<int> nop;
vector<int> idk;
int art=0, azal=0, kal=0;
bool yesb=false;
while (a!=b){
if (dept[a]<dept[b]) swap(b,a);
askarr.erase(getindex({a,par[a]}));
askarr.insert(i);
int crnum = ask(askarr);
if (crnum>origans){
nop.push_back(getindex({a,par[a]}));
yesb=true;
}
else if (crnum<origans){
yep.push_back(getindex({a,par[a]}));
}
else {
idk.push_back(getindex({a,par[a]}));
}
askarr.erase(i);
askarr.insert(getindex({a,par[a]}));
a=par[a];
}
if (yesb==true){
while (idk.size()){
yep.push_back(idk.back());
idk.pop_back();
}
}
else {
while (idk.size()){
nop.push_back(idk.back());
idk.pop_back();
}
}
if (yesb) hueh[i]=2;
else hueh[i]=0;
while (nop.size()){
hueh[nop.back()]=0;
nop.pop_back();
}
while (yep.size()){
hueh[yep.back()]=2;
yep.pop_back();
}
}
vector<int> final;
for (int i = 0; i < m; i++){
if (hueh[i]!=0) final.push_back(i);
}
//coutarr(final);
return final;
}
컴파일 시 표준 에러 (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... |