답안 #680664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680664 2023-01-11T13:40:33 Z Duy_e Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
280 ms 101112 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 dfs(int v) {

}

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] << ' ';
        for (int v: d[i]) {
            k --;
            write(v);
        }
    }
 
 
 
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:44: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]
   44 |         for (int id = 0; id < b.size(); id ++) {
      |                          ~~~^~~~~~~~~~
zalmoxis.cpp:48: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]
   48 |                 if (id + 1 < b.size() && b[id + 1].st == val)
      |                     ~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 244 ms 100284 KB Output is correct
2 Correct 280 ms 100892 KB Output is correct
3 Correct 250 ms 100596 KB Output is correct
4 Correct 269 ms 100680 KB Output is correct
5 Correct 258 ms 100736 KB Output is correct
6 Correct 265 ms 99876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 255 ms 100432 KB not a zalsequence
2 Incorrect 236 ms 99928 KB Expected EOF
3 Incorrect 255 ms 100764 KB Expected EOF
4 Incorrect 268 ms 100856 KB not a zalsequence
5 Incorrect 248 ms 100752 KB not a zalsequence
6 Incorrect 250 ms 100536 KB not a zalsequence
7 Incorrect 255 ms 100828 KB not a zalsequence
8 Incorrect 260 ms 101112 KB not a zalsequence
9 Incorrect 220 ms 95992 KB Expected EOF
10 Incorrect 161 ms 69412 KB Expected EOF
11 Incorrect 186 ms 76808 KB Expected EOF
12 Incorrect 98 ms 49176 KB not a zalsequence
13 Incorrect 100 ms 49352 KB not a zalsequence
14 Incorrect 105 ms 49184 KB not a zalsequence