제출 #1037934

#제출 시각아이디문제언어결과실행 시간메모리
1037934HydrolyzedTeleporters (IOI08_teleporters)C++14
0 / 100
164 ms29248 KiB
#include <bits/stdc++.h> using namespace std; const int MxP = 2000020; int nxt[MxP]; bool visited[MxP]; signed main(int argc, char *argv[]) { cin.tie(nullptr)->ios::sync_with_stdio(false); int n, m; cin >> n >> m; for(int i=0; i<MxP - 1; ++i) { nxt[i] = i + 1; } nxt[MxP - 1] = 1; for(int i=1, l, r; i<=n; ++i) { cin >> l >> r; nxt[l - 1] = r; nxt[r - 1] = l; } vector<int> v; for(int i=0; i<MxP; ++i) { if(visited[i]) { continue; } int cur = i, cnt_warp = 0; while(!visited[cur]) { visited[cur] = true; if(nxt[cur] != cur + 1) { cnt_warp++; } cur = nxt[cur]; } v.emplace_back(cnt_warp); } int answer = v[0] + (m + 1) / 2 + (m / 2) * 3; sort(v.begin(), v.end(), greater<int> ()); for(int i=0; i<m && i<(int) v.size(); ++i) { answer += 2 + v[i]; } cout << answer << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...