# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
839186 | 2023-08-29T02:50:19 Z | anha3k25cvp | Zalmoxis (BOI18_zalmoxis) | C++14 | 494 ms | 68716 KB |
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define dl double #define st first #define nd second #define II pair <int, int> using namespace std; const int N = 5 + 1e5; const int inf = 7 + 1e9; int main() { #define TASKNAME "" ios_base :: sync_with_stdio (0); cin.tie (0); if ( fopen( TASKNAME".inp", "r" ) ) { freopen (TASKNAME".inp", "r", stdin); freopen (TASKNAME".out", "w", stdout); } int n, k; cin >> n >> k; vector <int> a(n + k + 1, 0), nex(n + 1, 0), last(n + 1, 0); set <II> q; int mi = inf; for (int i = 1; i <= n; i ++) { cin >> a[i]; mi = min(mi, a[i]); q.insert({a[i], i}); last[i] = i; if (i < n) nex[i] = i + 1; } int cnt = n; vector <int> c(n + k + 1, 0), b = a; while (!q.empty()) { int val = q.begin() -> st, u = q.begin() -> nd; q.erase(q.begin()); if (val == 30) break; int v = nex[u]; if (v && b[v] == b[u]) { q.erase(q.begin()); c[last[u]] = v; last[u] = last[v]; nex[u] = nex[v]; q.insert({b[u] = val + 1, u}); } else { a[++ cnt] = val; c[last[u]] = cnt; last[u] = cnt; q.insert({b[u] = val + 1, u}); } } int pos = 1; n += k; for (int i = 1; i <= cnt; i ++) { if (a[pos] == mi) { int x = n - cnt + 1, k = 0; if (1 << (a[pos] - 1) <= x) { for (int j = 1; j <= (1 << (a[pos] - 1)); j ++) cout << "1 "; n -= (1 << (a[pos] - 1)) - 1; } else { for (; (1 << k) < x; k ++); a[pos] -= k; int y = (1 << k) - x; for (int j = 1; j <= x; j ++) if (j <= y) cout << a[pos] + 1 << ' '; else cout << a[pos] << ' '; n = cnt; } } else cout << a[pos] << ' '; pos = c[pos]; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 443 ms | 68556 KB | Unexpected end of file - int32 expected |
2 | Incorrect | 460 ms | 68684 KB | Unexpected end of file - int32 expected |
3 | Incorrect | 478 ms | 68636 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 456 ms | 68612 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 453 ms | 68652 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 453 ms | 68404 KB | Unexpected end of file - int32 expected |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 456 ms | 68612 KB | Unexpected end of file - int32 expected |
2 | Incorrect | 458 ms | 68464 KB | Unexpected end of file - int32 expected |
3 | Incorrect | 453 ms | 68556 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 458 ms | 68684 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 455 ms | 68556 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 475 ms | 68504 KB | Unexpected end of file - int32 expected |
7 | Incorrect | 463 ms | 68644 KB | Unexpected end of file - int32 expected |
8 | Incorrect | 494 ms | 68716 KB | Unexpected end of file - int32 expected |
9 | Incorrect | 391 ms | 57536 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 152 ms | 29264 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 257 ms | 40616 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 5 ms | 12112 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 5 ms | 11988 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 5 ms | 11988 KB | Unexpected end of file - int32 expected |