답안 #750163

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750163 2023-05-29T07:24:59 Z MrM7md Zalmoxis (BOI18_zalmoxis) C++17
40 / 100
266 ms 77972 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);
      }
      reverse(all(kk[i]));
      while(!kk[i].empty()&&k==0){
         ans[i].pb(kk[i].back());
         kk[i].pop_back();
      }
      // reverse(all(ans[i]));
   }

   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){
      |             ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 234 ms 77560 KB Output is correct
2 Correct 229 ms 77884 KB Output is correct
3 Correct 240 ms 77728 KB Output is correct
4 Correct 239 ms 77672 KB Output is correct
5 Correct 266 ms 77848 KB Output is correct
6 Correct 224 ms 77400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 245 ms 77616 KB not a zalsequence
2 Correct 243 ms 77392 KB Output is correct
3 Correct 228 ms 77820 KB Output is correct
4 Incorrect 246 ms 77880 KB not a zalsequence
5 Incorrect 266 ms 77728 KB not a zalsequence
6 Incorrect 249 ms 77660 KB not a zalsequence
7 Incorrect 250 ms 77804 KB not a zalsequence
8 Incorrect 265 ms 77972 KB not a zalsequence
9 Incorrect 251 ms 75852 KB not a zalsequence
10 Incorrect 173 ms 62104 KB not a zalsequence
11 Incorrect 182 ms 65716 KB not a zalsequence
12 Incorrect 109 ms 53252 KB not a zalsequence
13 Incorrect 116 ms 53296 KB not a zalsequence
14 Incorrect 113 ms 53332 KB not a zalsequence