# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
120237 | 2019-06-24T04:09:55 Z | nvmdava | Teleporters (IOI08_teleporters) | C++17 | 477 ms | 29088 KB |
#include <bits/stdc++.h> using namespace std; #define N 2000001 int to[2000005]; bool in[2000005]; int cnt; 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; } int res; 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()); for(int i = 0; i < v.size() && m--; i++){ res += v[i] + 2; } if(m >= 0)res += (m / 2 * 4) + (m % 2); cout<<res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 2276 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 2348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 2432 KB | Output is correct |
2 | Correct | 11 ms | 2688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 2432 KB | Output is correct |
2 | Correct | 12 ms | 2924 KB | Output is correct |
3 | Correct | 14 ms | 2936 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 2432 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 2532 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 4632 KB | Output is correct |
2 | Correct | 137 ms | 13600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 91 ms | 7912 KB | Output is correct |
2 | Correct | 244 ms | 17564 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 257 ms | 12312 KB | Output is correct |
2 | Correct | 314 ms | 23508 KB | Output is correct |
3 | Correct | 304 ms | 24784 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 378 ms | 12352 KB | Output is correct |
2 | Correct | 386 ms | 26196 KB | Output is correct |
3 | Correct | 330 ms | 24612 KB | Output is correct |
4 | Correct | 343 ms | 24696 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 395 ms | 14444 KB | Output is correct |
2 | Correct | 477 ms | 28960 KB | Output is correct |
3 | Correct | 221 ms | 28776 KB | Output is correct |
4 | Correct | 366 ms | 29088 KB | Output is correct |