# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
777994 | jamezzz | Teleporters (IOI08_teleporters) | C++17 | 985 ms | 65536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define INF 1023456789
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
typedef pair<int,int> ii;
#define maxn 1000005
int n,m,s[maxn],e[maxn],par[maxn<<2],sz[maxn<<2];
vector<ii> v;
int fp(int i){
return par[i]==i?i:par[i]=fp(par[i]);
}
void join(int x,int y){
x=fp(x),y=fp(y);
if(x==y)return;
if(sz[x]<sz[y])swap(x,y);
par[y]=x;
sz[x]+=sz[y];
}
int main(){
sf("%d%d",&n,&m);
for(int i=0;i<2*(m+n);++i)par[i]=i,sz[i]=1;
for(int i=0;i<n;++i){
sf("%d%d",&s[i],&e[i]);
v.pb({s[i],2*i});
v.pb({e[i],2*i+1});
}
sort(all(v));
int src=v[0].se;
for(auto[x,i]:v){
int y=(i%2)?s[i>>1]:e[i>>1];//other endpoint
int pos=lower_bound(all(v),ii(y+1,-1))-v.begin();
if(pos==sz(v))continue;
int j=v[pos].se;
join(i,j);
}
vector<int> s;
for(int i=0;i<2*n;++i){
if(fp(i)==i&&fp(i)!=fp(src)){
s.pb(sz[i]);
}
}
int ans=sz[fp(src)];
sort(all(s));
for(int i=0;i<m;++i){
if(!s.empty()){
ans+=2+s.back();
s.pop_back();
}
else ans+=1,s.pb(1);
}
pf("%d\n",ans);
}
컴파일 시 표준 에러 (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... |
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |