| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1363606 | liptonek | Laser Strike (EGOI25_laserstrike) | C++20 | 3 ms | 492 KiB |
#include <bits/stdc++.h>
using namespace std;
void ann(int n)
{
vector<vector<int>> adj(n);
vector<int> deg(n,0);
for(int i=0; i<n-1; i++)
{
int u,v;
cin>>u>>v;
adj[u].push_back(v);
adj[v].push_back(u);
deg[u]++;
deg[v]++;
}
vector<int> order;
vector<int> parents;
vector<bool> removed(n,false);
priority_queue<int,vector<int>,greater<int>> pq;
for(int i=0; i<n; i++)
{
if(deg[i]==1)
{
pq.push(i);
}
}
while(order.size()<(size_t)(n-1))
{
if(pq.empty())
{
break;
}
int u=pq.top();
pq.pop();
if(removed[u] || deg[u]==0)
{
continue;
}
int parent=-1;
for(int v : adj[u])
{
if(!removed[v])
{
parent=v;
break;
}
}
if(parent==-1)
{
continue;
}
order.push_back(u);
parents.push_back(parent);
removed[u]=true;
deg[parent]--;
if(deg[parent]==1)
{
pq.push(parent);
}
}
string msg="";
for(int i=0; i<n-1; i++)
{
if(order[i]<parents[i])
{
msg+='0';
}
else
{
msg+='1';
}
}
cout<<msg<<endl;
for(int x : order)
{
cout<<x<<endl;
}
}
void kathrin(int n)
{
string msg;
cin>>msg;
for(int i=0; i<n-1; i++)
{
int a,b;
cin>>a>>b;
if(msg[i]=='0')
{
cout<<a<<endl;
}
else
{
cout<<b<<endl;
}
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int p,n;
cin>>p>>n;
if(p==1)
{
ann(n);
}
else
{
kathrin(n);
}
return 0;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
