# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83411 | Tusk | Teleporters (IOI08_teleporters) | C++14 | 636 ms | 36992 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6+1;
int n, m;
bitset<N> chk;
int sz[N], mp[N], pos[N], comp;
vector<int> dp(N);
int main() {
scanf("%d %d", &n, &m);
for(int i = 1, a, b; i <= n; i++) {
scanf("%d %d", &a, &b);
mp[a] = b, mp[b] = a;
++dp[a], ++dp[b];
}
int ptr = 0;
for(int i = 1; i < N; i++) {
dp[i] += dp[i-1];
if(dp[i] != dp[i-1]) pos[ptr++] = i;
}
for(int i = 0; i < 2*n; i++) if(!chk[i]) {
++comp;
chk[i] = true;
int u = i;
while(1) {
++sz[comp];
int v = dp[mp[pos[u]]];
if(chk[v] || v == 2*n) break;
chk[v] = true;
u = v;
}
}
int ans = sz[1];
for(int i = 2; i <= comp; i++) dp[i-2] = sz[i];
sort(dp.begin(), dp.begin() + comp - 1, greater<int>());
for(int i = 0; i < comp-1 && m; i++, m--) ans += dp[i] + 2;
if(m) ans += 2*(m - (m & 1)) + (m & 1);
printf("%d\n", ans);
return 0;
}
컴파일 시 표준 에러 (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... |