| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 254865 | Lawliet | 다리 (APIO19_bridges) | C++17 | 120 ms | 7864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int MAXN = 50010;
const int MAXQ = 100010;
int n, m, q;
int ans[MAXQ];
int anc[MAXN], sz[MAXN];
vector< pair<int,pii> > sweep;
int find(int cur)
{
if( anc[cur] == cur ) return cur;
return anc[cur] = find( anc[cur] );
}
void join(int i, int j)
{
i = find(i); j = find(j);
if( i == j ) return;
if( sz[i] < sz[j] )
swap( i , j );
anc[j] = i;
sz[i] += sz[j];
}
int main()
{
scanf("%d %d",&n,&m);
for(int i = 1 ; i <= n ; i++)
sz[i] = 1, anc[i] = i;
for(int i = 1 ; i <= m ; i++)
{
int U, V, W;
scanf("%d %d %d",&U,&V,&W);
sweep.push_back( { W , { U , V } } );
}
scanf("%d",&q);
for(int i = 1 ; i <= q ; i++)
{
int s, maxW;
scanf("%*d %d %d",&s,&maxW);
sweep.push_back( { maxW , { -s , i } } );
}
sort( sweep.begin() , sweep.end() );
reverse( sweep.begin() , sweep.end() );
for(int i = 0 ; i < (int)sweep.size() ; i++)
{
int U = sweep[i].second.first;
int V = sweep[i].second.second;
if( U > 0 ) join( U , V );
else ans[V] = sz[ find(-U) ];
}
for(int i = 1 ; i <= q ; i++)
printf("%d\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... | ||||
