# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
382282 | couplefire | 조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2) | C++17 | 1099 ms | 73244 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const int N = 1e5 + 10;
set<int> in[N], out[N], com[N], e[N];
long long ans;
long long par[N], sz[N];
int n, m;
int find( int u ) { return par[u] == u ? u : par[u] = find( par[u] ); }
long long cal( int u ) { return 1LL * ( ( ( int )e[u].size() - sz[u] ) * sz[u] ) + 1LL * sz[u] * ( sz[u]-1 ); }
void merge( int a, int b ) {
vector<pii> v;
a = find( a ), b = find( b );
if( a == b ) return ;
if( in[a].size() + out[a].size() + e[a].size() < in[b].size() + out[b].size() + e[b].size() ) swap( a, b );
ans -= cal( a ), ans -= cal( b );
in[a].erase( b ), in[b].erase( a ), out[a].erase( b ), out[b].erase( a );
for( int x : in[b] ) {
if( out[a].count( x ) ) v.emplace_back( x, a );
out[x].erase( b ), out[x].emplace( a );
}
for( int x : out[b] ) {
if( in[a].count( x ) ) v.emplace_back( x, a );
컴파일 시 표준 에러 (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... |