Submission #431170

# Submission time Handle Problem Language Result Execution time Memory
431170 2021-06-17T10:06:02 Z Abdulmohsen1284 Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
227 ms 47176 KB
//#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
long long a[2000005];
vector <long long> plc[1000006];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n,k;
    cin>>n>>k;
    vector < pair <long long, long long> > v;
    vector <long long> ans;
    v.push_back({-1,0});
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        long long cur=a[i],m=a[i];
        bool ad=false;
        //cout<<"bruh"<<endl;
        //if(v.size()>0){
        while(cur==v[v.size()-1].first)
        {
            v.pop_back();
            cur++;
            ad=true;
            m=cur;
            if(v.size()==0)
                break;
        }
            v.push_back({m,i});
    }
    if(v.size()==2)
    {
        for(int i=0;i<n;i++)
        {
            cout<<a[i]<<" ";
        }
        for(int i=0;i<k;i++)
        {
            cout<<v[1].first+i<<" ";
        }
        return 0;
    }
    sort(v.begin(),v.end());
    plc[v[1].second].push_back(v[1].first);

    for(int i=2;i<v.size();i++)
    {
        if(v[i].first>v[i-1].first+1)
        {
            for(int j=v[i-1].first;j<v[i].first;j++)
            {
                plc[v[i-1].second].push_back(j);
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        ans.push_back(a[i]);
        for(int j=0;j<plc[i].size();j++)
            ans.push_back(plc[i][j]);
    }
    long long ma=0;

    for(int i=0;i<v.size();i++)
    {
        ma=max(ma,v[i].first);
    }
    for(int i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" ";
    }
    for(int i=0;i<(n+k)-ans.size();i++)
    {
        cout<<ma+i+1<<" ";
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:20:14: warning: variable 'ad' set but not used [-Wunused-but-set-variable]
   20 |         bool ad=false;
      |              ^~
zalmoxis.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i=2;i<v.size();i++)
      |                 ~^~~~~~~~~
zalmoxis.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int j=0;j<plc[i].size();j++)
      |                     ~^~~~~~~~~~~~~~
zalmoxis.cpp:67:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
zalmoxis.cpp:71:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     for(int i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
zalmoxis.cpp:75:18: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   75 |     for(int i=0;i<(n+k)-ans.size();i++)
      |                 ~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 189 ms 41636 KB Output is correct
2 Correct 191 ms 41644 KB Output is correct
3 Correct 192 ms 41740 KB Output is correct
4 Correct 189 ms 41640 KB Output is correct
5 Correct 193 ms 41632 KB Output is correct
6 Correct 190 ms 41636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 190 ms 41636 KB not a zalsequence
2 Incorrect 199 ms 41852 KB not a zalsequence
3 Incorrect 192 ms 41900 KB not a zalsequence
4 Incorrect 192 ms 41632 KB not a zalsequence
5 Incorrect 190 ms 41616 KB not a zalsequence
6 Incorrect 192 ms 41732 KB not a zalsequence
7 Incorrect 192 ms 41680 KB not a zalsequence
8 Incorrect 192 ms 41712 KB not a zalsequence
9 Incorrect 227 ms 47176 KB not a zalsequence
10 Incorrect 171 ms 37132 KB not a zalsequence
11 Incorrect 194 ms 44536 KB not a zalsequence
12 Incorrect 105 ms 30660 KB not a zalsequence
13 Incorrect 105 ms 30656 KB not a zalsequence
14 Incorrect 105 ms 30672 KB not a zalsequence