# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
53983 | khsoo01 | Teleporters (IOI08_teleporters) | C++11 | 1062 ms | 63356 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int N = 2000005;
int n, m, d[N], ans;
bool vis[N];
pii a[N];
vector<int> cpr, cs;
int cmpr (int V) {
return lower_bound(cpr.begin(), cpr.end(), V) - cpr.begin();
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) {
scanf("%d%d",&a[i].X,&a[i].Y);
cpr.push_back(a[i].X);
cpr.push_back(a[i].Y);
}
sort(cpr.begin(), cpr.end());
for(int i=1;i<=n;i++) {
a[i].X = cmpr(a[i].X);
a[i].Y = cmpr(a[i].Y);
d[a[i].X] = a[i].Y+1;
d[a[i].Y] = a[i].X+1;
}
for(int i=0;!vis[i];i=d[i]) {
ans++;
vis[i] = true;
}
for(int i=0;i<cpr.size();i++) {
if(vis[i]) continue;
int C = 0;
for(int j=i;!vis[j];j=d[j]) {
C++;
vis[j] = true;
}
cs.push_back(C);
}
sort(cs.begin(), cs.end());
for(int i=cs.size();i--;) {
if(!m) break;
m--;
ans += cs[i] + 2;
}
for(int i=0;i<m;i++) {
ans += i%2*2 + 1;
}
printf("%d\n", ans-1);
}
컴파일 시 표준 에러 (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... |