답안 #647983

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

using namespace std;

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(elem.second == 1)
                ans.push_back(elem.first);
            else if(diff != 0)
            {
                diff++;
                if((1 << elem.first) >= diff)
                {
                    for(int i = 0; i <= elem.first; i++)
                    {
                        if(!((1 << i) & diff))
                            continue;
                        for(int j = 0; j < (1 << i); j++)
                            ans.push_back(elem.first - i - 1);
                    }
                    diff = 0;
                }
                else
                {
                    diff -= (1 << elem.first);
                    for(int i = 0; i < (1 << elem.first); i++)
                        ans.push_back(0);
                }
            }
            else
                ans.push_back(elem.first);
        }
    }
    for(int elem : ans)
        cout << elem << ' ';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 163 ms 13900 KB Unexpected end of file - int32 expected
2 Incorrect 149 ms 13888 KB Unexpected end of file - int32 expected
3 Incorrect 156 ms 13984 KB Unexpected end of file - int32 expected
4 Incorrect 175 ms 13956 KB Unexpected end of file - int32 expected
5 Incorrect 154 ms 13988 KB Unexpected end of file - int32 expected
6 Incorrect 162 ms 14004 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 254 ms 23480 KB not a zalsequence
2 Incorrect 166 ms 13924 KB Unexpected end of file - int32 expected
3 Correct 263 ms 23536 KB Output is correct
4 Incorrect 245 ms 23528 KB not a zalsequence
5 Incorrect 253 ms 23552 KB not a zalsequence
6 Incorrect 247 ms 23516 KB not a zalsequence
7 Incorrect 275 ms 23648 KB not a zalsequence
8 Incorrect 255 ms 23484 KB not a zalsequence
9 Incorrect 229 ms 21332 KB not a zalsequence
10 Incorrect 144 ms 11636 KB not a zalsequence
11 Incorrect 168 ms 18288 KB not a zalsequence
12 Incorrect 87 ms 6224 KB not a zalsequence
13 Incorrect 84 ms 6280 KB not a zalsequence
14 Incorrect 90 ms 6320 KB not a zalsequence