Submission #750161

# Submission time Handle Problem Language Result Execution time Memory
750161 2023-05-29T07:22:50 Z MrM7md Zalmoxis (BOI18_zalmoxis) C++17
35 / 100
266 ms 77940 KB
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
const int N=1e6+500;
const int off=(1<<18);
const int MOD = 1e9+7;


vector<vector<int>>kk(N),ans(N);
signed main(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int n,k;
   cin >> n >> k;
   vector<pair<int,int>> a(n);
   for(int i=0;i<n;i++){
      cin >> a[i].F;
      a[i].S=i;
   }
   vector<pair<int,int>>v=a;
   for(int i=0;i<=29;i++){
      vector<pair<int,int>>t;
      for(int j=0;j<v.size();j++){
         if(j+1<v.size()&&v[j].F==v[j+1].F&&v[j].F==i){
            t.pb({v[j].F+1,v[j+1].S});

            j++;
         }
         else if(v[j].F==i){
            t.pb({v[j].F+1,v[j].S});
            kk[v[j].S].pb(v[j].F);
            k--;
         }
         else{
            t.pb(v[j]);
         }
      }
      v=t;
   }
   for(int i=0;i<n;i++){
      while(!kk[i].empty()&&k>0){
         int x=kk[i].back();
         if(x==0){
            ans[i].pb(x);
            kk[i].pop_back();
            continue;
         }
         k--;
         kk[i].pop_back();
         kk[i].pb(x-1),kk[i].pb(x-1);
      }
      while(!kk[i].empty()&&k==0){
         ans[i].pb(kk[i].back());
         kk[i].pop_back();
      }
   }

   for(int i=0;i<n;i++){
      cout<<a[i].F<<' ';
      for(auto it:ans[i])cout<<it<<' ';
   }
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:27: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]
   27 |       for(int j=0;j<v.size();j++){
      |                   ~^~~~~~~~~
zalmoxis.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |          if(j+1<v.size()&&v[j].F==v[j+1].F&&v[j].F==i){
      |             ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 216 ms 77544 KB Output is correct
2 Correct 214 ms 77912 KB Output is correct
3 Correct 236 ms 77708 KB Output is correct
4 Correct 224 ms 77796 KB Output is correct
5 Correct 238 ms 77796 KB Output is correct
6 Correct 213 ms 77372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 229 ms 77612 KB not a zalsequence
2 Correct 219 ms 77352 KB Output is correct
3 Incorrect 232 ms 77784 KB not a zalsequence
4 Incorrect 243 ms 77832 KB not a zalsequence
5 Incorrect 266 ms 77724 KB not a zalsequence
6 Incorrect 230 ms 77644 KB not a zalsequence
7 Incorrect 248 ms 77724 KB not a zalsequence
8 Incorrect 233 ms 77940 KB not a zalsequence
9 Incorrect 231 ms 75860 KB not a zalsequence
10 Incorrect 168 ms 62124 KB not a zalsequence
11 Incorrect 201 ms 65624 KB not a zalsequence
12 Incorrect 115 ms 53300 KB not a zalsequence
13 Incorrect 122 ms 53292 KB not a zalsequence
14 Incorrect 116 ms 53368 KB not a zalsequence