답안 #680682

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680682 2023-01-11T13:55:53 Z Duy_e Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
295 ms 100772 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);
        k--;
        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: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)
      |                     ~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 268 ms 100032 KB Output is correct
2 Correct 255 ms 100636 KB Output is correct
3 Correct 295 ms 100176 KB Output is correct
4 Correct 271 ms 100348 KB Output is correct
5 Correct 266 ms 100452 KB Output is correct
6 Correct 262 ms 99664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 263 ms 100176 KB Unexpected end of file - int32 expected
2 Incorrect 270 ms 99628 KB Unexpected end of file - int32 expected
3 Incorrect 263 ms 100560 KB Unexpected end of file - int32 expected
4 Incorrect 262 ms 100644 KB Unexpected end of file - int32 expected
5 Incorrect 259 ms 100432 KB Unexpected end of file - int32 expected
6 Incorrect 268 ms 100080 KB Unexpected end of file - int32 expected
7 Incorrect 246 ms 100436 KB Unexpected end of file - int32 expected
8 Incorrect 265 ms 100772 KB Unexpected end of file - int32 expected
9 Incorrect 242 ms 95472 KB Unexpected end of file - int32 expected
10 Incorrect 136 ms 68384 KB Unexpected end of file - int32 expected
11 Incorrect 166 ms 76044 KB Unexpected end of file - int32 expected
12 Incorrect 62 ms 48224 KB Unexpected end of file - int32 expected
13 Incorrect 67 ms 48256 KB Unexpected end of file - int32 expected
14 Incorrect 82 ms 48204 KB Unexpected end of file - int32 expected