| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 910863 | ibm2006 | 다리 (APIO19_bridges) | C++17 | 82 ms | 18860 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,i,j,k,l,r,x,y,z,w,s,t,m,q,e,ee,a[1100000],h[1100000],dep[1100000],ans[1100000];
vector<pair<pair<ll,ll>,pair<ll,ll>>> u;
pair<pair<ll,ll>,pair<ll,ll>> pq;
ll f(ll x)
{
if(a[x]==x)
return x;
a[x]=f(a[x]);
return a[x];
}
void g(ll x,ll y)
{
x=f(x);
y=f(y);
if(x==y)
return;
if(dep[x]>dep[y])
swap(x,y);
dep[y]+=dep[x];
a[x]=y;
}
int main()
{
scanf("%lld %lld",&n,&m);
for(i=1;i<=n;i++)
{
a[i]=i;
dep[i]=1;
}
for(i=1;i<=m;i++)
{
scanf("%lld %lld %lld",&x,&y,&z);
u.push_back({{-z,1},{x,y}});
}
scanf("%lld",&q);
for(i=1;i<=q;i++)
{
scanf("%lld %lld %lld",&x,&y,&z);
u.push_back({{-z,2},{i,y}});
}
sort(u.begin(),u.end());
for(e=0;e<u.size();e++)
{
pq=u[e];
if(pq.first.second==1)
{
x=pq.second.first;
y=pq.second.second;
g(x,y);
continue;
}
x=pq.second.first;
y=pq.second.second;
ans[x]=dep[f(y)];
}
for(i=1;i<=q;i++)
{
printf("%lld\n",ans[i]);
}
}
컴파일 시 표준 에러 (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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
