# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
163592 | 2019-11-14T07:11:50 Z | nvmdava | Teleporters (IOI08_teleporters) | C++17 | 437 ms | 29004 KB |
#include <bits/stdc++.h> using namespace std; #define N 2000001 int to[2000005]; bool in[2000005]; int cnt; int res; void go(int i){ if(in[i] || i > N) return; in[i] = 1; i++; if(to[i]){ i = to[i]; cnt++; } go(i); } vector<int> v; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin>>n>>m; for(int i = 1; i <= n; i++){ int w, e; cin>>w>>e; to[w] = e; to[e] = w; } for(int i = 0; i <= N; i++){ if(!in[i]){ cnt = 0; go(i); if(i == 0) res = cnt; else v.push_back(cnt); } } sort(v.rbegin(), v.rend()); if(m < v.size()) v.resize(m); m -= v.size(); if(m >= 0)res += (m >> 1 << 2) + (m % 2); for(int i : v) res += i + 2; cout<<res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2300 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2268 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2284 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 2424 KB | Output is correct |
2 | Correct | 13 ms | 2652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 2424 KB | Output is correct |
2 | Correct | 22 ms | 2936 KB | Output is correct |
3 | Correct | 26 ms | 2936 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 2552 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 2680 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 6256 KB | Output is correct |
2 | Correct | 147 ms | 13688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 98 ms | 10744 KB | Output is correct |
2 | Correct | 209 ms | 17468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 283 ms | 21456 KB | Output is correct |
2 | Correct | 339 ms | 23144 KB | Output is correct |
3 | Correct | 324 ms | 24808 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 406 ms | 25068 KB | Output is correct |
2 | Correct | 437 ms | 26220 KB | Output is correct |
3 | Correct | 384 ms | 24568 KB | Output is correct |
4 | Correct | 378 ms | 24668 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 436 ms | 28948 KB | Output is correct |
2 | Correct | 433 ms | 29004 KB | Output is correct |
3 | Correct | 279 ms | 28640 KB | Output is correct |
4 | Correct | 413 ms | 28804 KB | Output is correct |