# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
855752 | 2023-10-01T17:49:47 Z | faruk | Zalmoxis (BOI18_zalmoxis) | C++17 | 188 ms | 20832 KB |
#include <bits/stdc++.h> #define mp make_pair #define all(a) a.begin(), a.end() using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef set<pii>::iterator ite; const int MX = 30; struct sequence { vector<vector<int>> idxs; sequence() { idxs.resize(MX+1); } sequence(vector<int> arr) { idxs.resize(MX+1); for (int i = 0; i < arr.size(); i++) idxs[arr[i]].push_back(i); } }; void merge_lowest(int lowest, sequence &seq) { sort(all(seq.idxs[lowest])); for (int i = 0; i < seq.idxs[lowest].size(); i += 2) seq.idxs[lowest + 1].push_back(seq.idxs[lowest][0]); seq.idxs[lowest].clear(); } vector<pii> reconstruct(sequence seq) { vector<pii> out; for (int i = 0; i <= MX; i++) { for (int a : seq.idxs[i]) out.push_back({a, i}); } sort(all(out)); return out; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; int needed = 1 << 30; vector<int> arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; needed -= 1 << arr[i]; } needed = log2(needed); int lowest = *min_element(all(arr)); sequence seq(arr); for (;lowest < needed; lowest++) merge_lowest(lowest, seq); vector<pii> new_arr = reconstruct(seq); int s = 0, b = -1; int where_to_insert; for (int i = 0; i <= new_arr.size(); i++) { if (i == new_arr.size() || new_arr[i].second != needed) { if (s % 2 == 1) { where_to_insert = b; break; } s = 0, b = -1; } else if (new_arr[i].second == needed) { if (s == 0) b = new_arr[i].first; s++; } } arr.insert(arr.begin() + where_to_insert, needed); for (int a : arr) cout << a << " "; cout << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 163 ms | 19644 KB | not a zalsequence |
2 | Incorrect | 165 ms | 19732 KB | not a zalsequence |
3 | Incorrect | 183 ms | 20060 KB | not a zalsequence |
4 | Incorrect | 175 ms | 19784 KB | not a zalsequence |
5 | Incorrect | 188 ms | 19860 KB | not a zalsequence |
6 | Incorrect | 169 ms | 20832 KB | not a zalsequence |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 167 ms | 19212 KB | Unexpected end of file - int32 expected |
2 | Incorrect | 174 ms | 19792 KB | Unexpected end of file - int32 expected |
3 | Incorrect | 177 ms | 20556 KB | Unexpected end of file - int32 expected |
4 | Incorrect | 169 ms | 19948 KB | Unexpected end of file - int32 expected |
5 | Incorrect | 163 ms | 19448 KB | Unexpected end of file - int32 expected |
6 | Incorrect | 180 ms | 19948 KB | Unexpected end of file - int32 expected |
7 | Incorrect | 165 ms | 20784 KB | Unexpected end of file - int32 expected |
8 | Incorrect | 157 ms | 20288 KB | Unexpected end of file - int32 expected |
9 | Incorrect | 129 ms | 15320 KB | Unexpected end of file - int32 expected |
10 | Incorrect | 58 ms | 6444 KB | Unexpected end of file - int32 expected |
11 | Incorrect | 83 ms | 10172 KB | Unexpected end of file - int32 expected |
12 | Incorrect | 0 ms | 348 KB | Unexpected end of file - int32 expected |
13 | Incorrect | 0 ms | 348 KB | Unexpected end of file - int32 expected |
14 | Incorrect | 1 ms | 344 KB | Unexpected end of file - int32 expected |