답안 #647952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
647952 2022-10-04T17:03:39 Z toma_ariciu Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
204 ms 14840 KB
/// Preset de orice altceva
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

ifstream fin("test.in");
ofstream fout("test.out");

int n, k, v[1000005], ind, diff;
vector <pair<int, bool>> sol;
vector <int> ans;

void dfs(int val)
{
    if(val == -1)
        return;
    if(v[ind] == val)
    {
        ind++;
        sol.push_back({val, 1});
        return;
    }
    if(v[ind] < val)
    {
        dfs(val - 1);
        dfs(val - 1);
    }
    else
        sol.push_back({val, 0});
}

int main()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    v[n + 1] = 31;
    ind = 1;
    dfs(30);
    diff = n + k - sol.size();
    if(diff != 0)
    {
        for(auto elem : sol)
        {
            if(diff == 0)
                break;
            if(elem.second == 1)
                ans.push_back(elem.first);
            else
            {
                if((1LL << elem.first) > (diff + 1))
                {
                    diff++;
                    for(int i = 0; i < elem.first; i++)
                    {
                        if(!((1LL << i) & diff))
                            continue;
                        for(int j = 0; j < (1 << i); j++)
                            ans.push_back(elem.first - i - 1);
                    }
                    diff = 0;
                }
                else
                {
                    diff -= (1LL << elem.first);
                    diff++;
                    for(int i = 0; i < (1LL << elem.first); i++)
                        ans.push_back(0);
                }
            }
        }
    }
    for(int elem : ans)
        cout << elem << ' ';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 164 ms 14624 KB Unexpected end of file - int32 expected
2 Incorrect 163 ms 14548 KB Unexpected end of file - int32 expected
3 Incorrect 173 ms 14556 KB Unexpected end of file - int32 expected
4 Incorrect 179 ms 14612 KB Unexpected end of file - int32 expected
5 Incorrect 161 ms 14564 KB Unexpected end of file - int32 expected
6 Incorrect 157 ms 14484 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 175 ms 14508 KB Unexpected end of file - int32 expected
2 Incorrect 158 ms 14564 KB Unexpected end of file - int32 expected
3 Incorrect 174 ms 14500 KB Unexpected end of file - int32 expected
4 Incorrect 157 ms 14624 KB Unexpected end of file - int32 expected
5 Incorrect 204 ms 14620 KB Unexpected end of file - int32 expected
6 Incorrect 159 ms 14504 KB Unexpected end of file - int32 expected
7 Incorrect 173 ms 14616 KB Unexpected end of file - int32 expected
8 Incorrect 166 ms 14840 KB Unexpected end of file - int32 expected
9 Incorrect 141 ms 12240 KB Unexpected end of file - int32 expected
10 Incorrect 98 ms 11564 KB Unexpected end of file - int32 expected
11 Incorrect 115 ms 12220 KB Unexpected end of file - int32 expected
12 Incorrect 78 ms 6364 KB Unexpected end of file - int32 expected
13 Incorrect 83 ms 6356 KB Unexpected end of file - int32 expected
14 Incorrect 86 ms 6336 KB Unexpected end of file - int32 expected