제출 #712103

#제출 시각아이디문제언어결과실행 시간메모리
712103wenqiZalmoxis (BOI18_zalmoxis)C++17
100 / 100
173 ms8408 KiB
// trans rights
#include <bits/extc++.h>
using namespace std;
using ll = long long;

int N, K;

int inp[1000069];

stack<int> f;
vector<pair<int, int>> probes;

void probe(int x)
{
    while (f.size() and x == f.top())
    {
        f.pop();
        x++;
    }
    f.push(x);
}

void curse(int x, int &u)
{
    if (x and u)
    {
        u--;
        curse(x - 1, u);
        curse(x - 1, u);
    }else{
        cout << x << ' ';
    }
}

int main(int argc, const char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> K;
    for (int i = 0; i <= N; i++)
    {
        int x = 30;
        if (i < N)
            cin >> x;
        inp[i] = x;
        while (f.size() and x > f.top())
        {
            probes.emplace_back(f.top(), i);
            probe(f.top());
        }
        if (i < N)
            probe(x);
    }
    int lo = K - probes.size();
    int ptr = 0;
    for (int i = 0; i <= N; i++)
    {
        while (ptr < probes.size() and probes[ptr].second <= i)
        {
            curse(probes[ptr].first, lo);
            ptr++;
        }
        if (i < N)
            cout << inp[i] << ' ';
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

zalmoxis.cpp: In function 'int main(int, const char**)':
zalmoxis.cpp:58:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         while (ptr < probes.size() and probes[ptr].second <= i)
      |                ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...