답안 #750128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750128 2023-05-29T07:02:30 Z MrM7md Zalmoxis (BOI18_zalmoxis) C++17
70 / 100
369 ms 139228 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;
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<array<int,3>> a(n);
   for(int i=0;i<n;i++){
      cin >> a[i][0];
      a[i][1]=a[i][2]=i;
   }
   vector<array<int,3>>v=a;
   for(int i=0;i<=29;i++){
      vector<array<int,3>>t;
      for(int j=0;j<v.size();j++){
         if(j+1<v.size()&&v[j][0]==v[j+1][0]&&v[j][0]==i){
            t.pb({v[j][0]+1,v[j][1],v[j+1][2]});

            j++;
         }
         else if(v[j][0]==i){
            t.pb({v[j][0]+1,v[j][1],v[j][2]});
            kk[v[j][2]].pb(v[j][0]);
            // sort(all(kk[v[j][2]]));
            k--;
            // cout<<kk.F<<endl;
         }
         else{
            t.pb(v[j]);
         }
      }
      v=t;
   }
   for(int i=0;i<n;i++){
      for(auto it:kk[i]){
         ans[i].pb(it);
         while(!ans[i].empty()&&k>0&&ans[i].back()>1){
            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][0]<<' ';
      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: 'long long int' and 'std::vector<std::array<long long int, 3> >::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: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |          if(j+1<v.size()&&v[j][0]==v[j+1][0]&&v[j][0]==i){
      |             ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 282 ms 138176 KB Output is correct
2 Correct 329 ms 138940 KB Output is correct
3 Correct 369 ms 138416 KB Output is correct
4 Correct 297 ms 138516 KB Output is correct
5 Correct 360 ms 138772 KB Output is correct
6 Correct 269 ms 137432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 301 ms 138272 KB Output is correct
2 Correct 276 ms 137464 KB Output is correct
3 Correct 298 ms 138788 KB Output is correct
4 Correct 325 ms 138900 KB Output is correct
5 Correct 318 ms 138568 KB Output is correct
6 Correct 312 ms 138292 KB Output is correct
7 Incorrect 301 ms 138692 KB Unexpected end of file - int32 expected
8 Incorrect 305 ms 139228 KB Unexpected end of file - int32 expected
9 Correct 258 ms 127984 KB Output is correct
10 Incorrect 179 ms 82384 KB Unexpected end of file - int32 expected
11 Correct 210 ms 95716 KB Output is correct
12 Incorrect 26 ms 47224 KB Unexpected end of file - int32 expected
13 Incorrect 28 ms 47292 KB Unexpected end of file - int32 expected
14 Incorrect 25 ms 47276 KB Unexpected end of file - int32 expected