# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
274687 | 2020-08-19T14:11:32 Z | evpipis | Regions (IOI09_regions) | C++11 | 118 ms | 6760 KB |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back typedef pair<int, int> ii; const int len = 2e6+5; int vis[len], nex[len]; vector<ii> vec; priority_queue<int> pq; int dfs(int u){ vis[u] = 1; int ans = 1; if (!vis[nex[u]]) ans += dfs(nex[u]); return ans; } int main(){ int n, m; scanf("%d %d", &n, &m); for (int i = 0; i < n; i++){ int a, b; scanf("%d %d", &a, &b); vec.pb(mp(a, 2*i)); vec.pb(mp(b, 2*i+1)); } sort(vec.begin(), vec.end()); for (int i = 0; i < 2*n-1; i++) nex[vec[i].se] = vec[i+1].se^1; int st = 2*n; nex[st] = vec[0].se^1; nex[vec[2*n-1].se] = st; vis[st] = 1; int ans = dfs(nex[st]); for (int i = 0; i < 2*n; i++) if (!vis[i]) pq.push(dfs(i)); while (m--){ if (pq.empty()) ans++, pq.push(1); else ans += 2+pq.top(), pq.pop(); } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Unexpected end of file - int32 expected |
2 | Incorrect | 0 ms | 384 KB | Unexpected end of file - int32 expected |
3 | Incorrect | 1 ms | 384 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 0 ms | 384 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 1 ms | 384 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 1 ms | 384 KB | Unexpected end of file - int32 expected |
7 | Incorrect | 1 ms | 384 KB | Unexpected end of file - int32 expected |
8 | Incorrect | 1 ms | 384 KB | Unexpected end of file - int32 expected |
9 | Incorrect | 3 ms | 640 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 5 ms | 768 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 8 ms | 1020 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 11 ms | 1144 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 14 ms | 1144 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 15 ms | 1400 KB | Unexpected end of file - int32 expected |
15 | Incorrect | 22 ms | 1652 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 35 ms | 2788 KB | Unexpected end of file - int32 expected |
2 | Incorrect | 45 ms | 2920 KB | Unexpected end of file - int32 expected |
3 | Incorrect | 42 ms | 3304 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 16 ms | 1400 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 22 ms | 1644 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 26 ms | 2028 KB | Unexpected end of file - int32 expected |
7 | Incorrect | 36 ms | 2660 KB | Unexpected end of file - int32 expected |
8 | Incorrect | 51 ms | 3556 KB | Unexpected end of file - int32 expected |
9 | Incorrect | 79 ms | 5212 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 106 ms | 5724 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 118 ms | 6748 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 114 ms | 6368 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 102 ms | 6364 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 109 ms | 6748 KB | Unexpected end of file - int32 expected |
15 | Incorrect | 106 ms | 6760 KB | Unexpected end of file - int32 expected |
16 | Incorrect | 114 ms | 6704 KB | Unexpected end of file - int32 expected |
17 | Incorrect | 105 ms | 6748 KB | Unexpected end of file - int32 expected |