답안 #644350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644350 2022-09-24T12:01:49 Z Kripton Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
146 ms 34876 KB
#include <bits/stdc++.h>
using namespace std;
int steve[1000001],vf;
int steve1[1000001],vf1;
int v[1000001],v1[1000001];
vector <int> addie[1000001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,i,x,j;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
        v1[i]=v[i];
        while(v[i]==v[steve[vf]])
        {
            v[i]++;
            vf--;
        }
        steve[++vf]=i;
    }
    for(j=1;j<=30&&k&&v[steve[vf]]!=30;j++)
    {
        int min1=40,ind;
        for(i=1;i<=vf;i++)
            min1=min(min1,v[steve[i]]);
        vf1=0;
        for(i=1;i<=vf;i++)
        {
            if(k&&v[steve[i]]==min1)
            {
                k--;
                v[steve[i]]++;
                addie[steve[i]].push_back(min1);
            }
            while(v[steve[i]]==v[steve1[vf1]])
            {
                v[steve[i]]++;
                vf1--;
            }
            steve1[++vf1]=steve[i];
        }
        vf=vf1;
        for(i=1;i<=vf;i++)
            steve[i]=steve1[vf1];
    }
    for(i=1;i<=n;i++)
    {
        cout<<v1[i]<<" ";
        for(auto it:addie[i])
        {
            if(k>=((1<<it)-1))
            {
                k-=((1<<it)-1);
                for(j=1;j<=(1<<it);j++)
                    cout<<"1 ";
                continue;
            }
            else if(k)
            {
                int a=(int)log2(k)+1;
                int newit=it-a;
                //daca fac (1<<a) newit-uri, k-=((1<<(a+1))-1)
                k-=((1<<a)-1);
                k=-k;
                for(j=1;j<=(1<<a)-2*k;j++)
                    cout<<newit<<" ";
                for(j=1;j<=k;j++)
                    cout<<newit+1<<" ";
                k=0;
            }
            else
                cout<<it<<" ";
        }
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:27:21: warning: unused variable 'ind' [-Wunused-variable]
   27 |         int min1=40,ind;
      |                     ^~~
zalmoxis.cpp:12:15: warning: unused variable 'x' [-Wunused-variable]
   12 |     int n,k,i,x,j;
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 135 ms 33976 KB Output is correct
2 Correct 136 ms 33916 KB Output is correct
3 Correct 146 ms 33920 KB Output is correct
4 Correct 135 ms 33996 KB Output is correct
5 Correct 139 ms 33892 KB Output is correct
6 Correct 138 ms 33868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 137 ms 33920 KB not a zalsequence
2 Incorrect 135 ms 33980 KB not a zalsequence
3 Incorrect 141 ms 34148 KB not a zalsequence
4 Incorrect 138 ms 33928 KB not a zalsequence
5 Incorrect 138 ms 33952 KB not a zalsequence
6 Incorrect 142 ms 34144 KB not a zalsequence
7 Incorrect 138 ms 34004 KB not a zalsequence
8 Incorrect 139 ms 33996 KB not a zalsequence
9 Incorrect 129 ms 34876 KB Unexpected end of file - int32 expected
10 Incorrect 59 ms 29316 KB Unexpected end of file - int32 expected
11 Incorrect 81 ms 31564 KB Unexpected end of file - int32 expected
12 Incorrect 53 ms 25804 KB not a zalsequence
13 Incorrect 54 ms 25756 KB not a zalsequence
14 Incorrect 52 ms 25804 KB not a zalsequence