Submission #680667

# Submission time Handle Problem Language Result Execution time Memory
680667 2023-01-11T13:42:31 Z Duy_e Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
297 ms 101372 KB
#include <bits/stdc++.h>
#define ll long long
#define st first
#define nd second
#define pii pair <ll, ll>
#define rep(i, n, m) for (ll i = (n); i <= (m); i ++)
#define rrep(i, n, m) for (ll i = (n); i >= (m); i --)
using namespace std;
const long long N = 2e6 + 10;
ll n, k, a[N], b[N], cnt;
vector <int> d[N];

void write(int v) {
    if (v == 0 || k == 0) {
        cout << v << ' ';
        return;
    }

    if (k > 0) {
        k --;
        write(v - 1);
        write(v - 1);
    }
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //freopen("test.inp", "r", stdin);

    cin >> n >> k;
    vector <pii> b;
 
    rep(i, 1, n) cin >> a[i], b.push_back({a[i], i});
 
    int cnt = 0;
    rep(val, 0, 29) {
        vector <pii> v;
        for (int id = 0; id < b.size(); id ++) {
            int x = b[id].st;
            if (val != x) v.push_back(b[id]);
            else {
                if (id + 1 < b.size() && b[id + 1].st == val)
                    v.push_back({val + 1, b[id + 1].nd}), id ++;
                else {
                    d[b[id].nd].push_back(val);
                    v.push_back({val + 1, b[id].nd});
                    k --;
                    cnt ++;
                    if (k == 0) break;
                }
            }
            if (k == 0) break;
        }
        if (k == 0) break;
        b = v;
    }
 
    k += cnt;
    rep(i, 1, n) {
        cout << a[i] << ' ';
        reverse(d[i].begin(), d[i].end());
        for (int v: d[i]) {
            k --;
            write(v);
        }
    }
 
 
 
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:40:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (int id = 0; id < b.size(); id ++) {
      |                          ~~~^~~~~~~~~~
zalmoxis.cpp:44:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |                 if (id + 1 < b.size() && b[id + 1].st == val)
      |                     ~~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 243 ms 100560 KB Output is correct
2 Correct 253 ms 101052 KB Output is correct
3 Correct 278 ms 100832 KB Output is correct
4 Correct 242 ms 100868 KB Output is correct
5 Correct 269 ms 100928 KB Output is correct
6 Correct 250 ms 100172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 260 ms 100688 KB not a zalsequence
2 Incorrect 244 ms 100328 KB Expected EOF
3 Incorrect 258 ms 101088 KB Expected EOF
4 Incorrect 297 ms 101188 KB not a zalsequence
5 Incorrect 260 ms 101008 KB not a zalsequence
6 Incorrect 244 ms 100616 KB not a zalsequence
7 Incorrect 283 ms 101076 KB not a zalsequence
8 Incorrect 273 ms 101372 KB not a zalsequence
9 Incorrect 230 ms 96284 KB Expected EOF
10 Incorrect 157 ms 69668 KB Expected EOF
11 Incorrect 188 ms 77072 KB Expected EOF
12 Incorrect 99 ms 49192 KB not a zalsequence
13 Incorrect 99 ms 49268 KB not a zalsequence
14 Incorrect 96 ms 49228 KB not a zalsequence