답안 #760753

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
760753 2023-06-18T10:46:02 Z LucaIlie Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
215 ms 47520 KB
#include <bits/stdc++.h>

using namespace std;

struct xxx {
    int l, r, val, ap;

    bool operator < ( const xxx &x ) const {
        return val < x.val;
    }
};

const int MAX_N = 1e6;
int v[MAX_N + 1], leftt[MAX_N + 1], rightt[MAX_N + 1], value[MAX_N + 1], apar[MAX_N + 1];
set<xxx> seg;
vector<int> adaugiri[MAX_N + 1];

int main() {
    int n, k;

    cin >> n >> k;
    for ( int i = 1; i <= n; i++ )
        cin >> v[i];

    int l = 1, r = 1;
    while ( l <= n ) {
        r = l;
        while ( r + 1 <= n && v[l] == v[r + 1] )
            r++;
        leftt[r] = l;
        rightt[l] = r;
        value[l] = value[r] = v[l];
        apar[l] = apar[r] = r - l + 1;
        seg.insert( { l, r, v[l], r - l + 1 } );
        l = r + 1;
    }

    while ( (!(seg.size() == 1 && seg.begin()->ap == 1)) ) {
        int l = seg.begin()->l, r = seg.begin()->r, val = seg.begin()->val, ap = seg.begin()->ap;
        seg.erase( { l, r, val, ap } );

        if ( ap % 2 == 1 ) {
            ap++;
            k--;
            adaugiri[r].push_back( val );
        }
        ap /= 2;
        val++;

        if ( val == value[l - 1] ) {
            ap += apar[l - 1];
            seg.erase( { leftt[l - 1], rightt[l - 1], value[l - 1], apar[l - 1] } );
            l = leftt[l - 1];
        }
        if ( val == value[r + 1] ) {
            ap += apar[r + 1];
            seg.erase( { leftt[r + 1], rightt[r + 1], value[r + 1], apar[r + 1] } );
            r = rightt[r + 1];
        }

        leftt[r] = l;
        rightt[l] = r;
        value[l] = value[r] = val;
        apar[l] = apar[r] = ap;
        seg.insert( { l, r, val, ap } );
    }

    for ( int i = 1; i <= n; i++ ) {
        cout << v[i] << " ";
        for ( int x: adaugiri[i] )
            cout << x << " ";
    }
    int val = seg.begin()->val;
    for ( int i = 0; i < k; i++ )
        cout << val + i << " ";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 202 ms 47468 KB Expected EOF
2 Incorrect 203 ms 47428 KB Expected EOF
3 Incorrect 208 ms 47428 KB Expected EOF
4 Incorrect 215 ms 47496 KB Expected EOF
5 Incorrect 203 ms 47388 KB Expected EOF
6 Incorrect 210 ms 47308 KB Expected EOF
# 결과 실행 시간 메모리 Grader output
1 Incorrect 208 ms 47468 KB not a zalsequence
2 Incorrect 214 ms 47408 KB not a zalsequence
3 Incorrect 206 ms 47436 KB not a zalsequence
4 Incorrect 212 ms 47520 KB not a zalsequence
5 Incorrect 209 ms 47440 KB not a zalsequence
6 Incorrect 201 ms 47440 KB not a zalsequence
7 Incorrect 202 ms 47388 KB not a zalsequence
8 Incorrect 204 ms 47420 KB not a zalsequence
9 Incorrect 183 ms 44064 KB not a zalsequence
10 Incorrect 120 ms 35676 KB not a zalsequence
11 Incorrect 145 ms 38976 KB not a zalsequence
12 Incorrect 85 ms 30836 KB not a zalsequence
13 Incorrect 81 ms 30668 KB not a zalsequence
14 Incorrect 81 ms 30728 KB not a zalsequence