답안 #680680

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680680 2023-01-11T13:54:51 Z Duy_e Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
299 ms 100776 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);
    
    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] << ' ';
        for (int v: d[i]) {
            k --;
            write(v);
            // cout << v << ' ';
        }
    }
 
 
 
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:38: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]
   38 |         for (int id = 0; id < b.size(); id ++) {
      |                          ~~~^~~~~~~~~~
zalmoxis.cpp:42: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]
   42 |                 if (id + 1 < b.size() && b[id + 1].st == val)
      |                     ~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 236 ms 100056 KB Output is correct
2 Correct 299 ms 100572 KB Output is correct
3 Correct 266 ms 100440 KB Output is correct
4 Correct 261 ms 100324 KB Output is correct
5 Correct 284 ms 100456 KB Output is correct
6 Correct 242 ms 99672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 240 ms 100096 KB not a zalsequence
2 Incorrect 235 ms 99620 KB Expected EOF
3 Incorrect 264 ms 100512 KB Expected EOF
4 Incorrect 249 ms 100660 KB not a zalsequence
5 Incorrect 251 ms 100312 KB not a zalsequence
6 Incorrect 291 ms 100132 KB not a zalsequence
7 Incorrect 254 ms 100592 KB not a zalsequence
8 Incorrect 254 ms 100776 KB not a zalsequence
9 Incorrect 232 ms 95736 KB Expected EOF
10 Incorrect 166 ms 69072 KB Expected EOF
11 Incorrect 203 ms 76484 KB Expected EOF
12 Incorrect 102 ms 49248 KB not a zalsequence
13 Incorrect 128 ms 49184 KB not a zalsequence
14 Incorrect 107 ms 49180 KB not a zalsequence