답안 #750154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750154 2023-05-29T07:16:06 Z MrM7md Zalmoxis (BOI18_zalmoxis) C++17
75 / 100
221 ms 77932 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++){
      for(auto it:kk[i]){
         ans[i].pb(it);
         while(k>0&&ans[i].back()>0){
            int x=ans[i].back()-1;
            ans[i].pop_back();
            ans[i].pb(x),ans[i].pb(x);
            k--;
         }
      }
   }
   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 208 ms 77524 KB Output is correct
2 Correct 211 ms 77816 KB Output is correct
3 Correct 208 ms 77712 KB Output is correct
4 Correct 215 ms 77728 KB Output is correct
5 Correct 218 ms 77808 KB Output is correct
6 Correct 200 ms 77328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 209 ms 77584 KB Output is correct
2 Correct 202 ms 77376 KB Output is correct
3 Correct 218 ms 77784 KB Output is correct
4 Correct 221 ms 77848 KB Output is correct
5 Correct 214 ms 77732 KB Output is correct
6 Correct 214 ms 77660 KB Output is correct
7 Incorrect 212 ms 77808 KB Unexpected end of file - int32 expected
8 Incorrect 215 ms 77932 KB Unexpected end of file - int32 expected
9 Correct 215 ms 75852 KB Output is correct
10 Correct 155 ms 61944 KB Output is correct
11 Correct 175 ms 65712 KB Output is correct
12 Incorrect 24 ms 47316 KB Unexpected end of file - int32 expected
13 Incorrect 23 ms 47320 KB Unexpected end of file - int32 expected
14 Incorrect 23 ms 47308 KB Unexpected end of file - int32 expected