답안 #750149

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750149 2023-05-29T07:11:28 Z MrM7md Zalmoxis (BOI18_zalmoxis) C++14
75 / 100
242 ms 93312 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<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]);

             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--;
         }
      }
   }
   int id=0;
   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: 'int' and 'std::vector<std::array<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: 'int' and 'std::vector<std::array<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){
      |             ~~~^~~~~~~~~
zalmoxis.cpp:56:8: warning: unused variable 'id' [-Wunused-variable]
   56 |    int id=0;
      |        ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 242 ms 92712 KB Output is correct
2 Correct 237 ms 93136 KB Output is correct
3 Correct 236 ms 92912 KB Output is correct
4 Correct 235 ms 92944 KB Output is correct
5 Correct 232 ms 93072 KB Output is correct
6 Correct 222 ms 92348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 235 ms 92784 KB Output is correct
2 Correct 229 ms 92384 KB Output is correct
3 Correct 234 ms 93068 KB Output is correct
4 Correct 236 ms 93128 KB Output is correct
5 Correct 239 ms 93108 KB Output is correct
6 Correct 232 ms 92812 KB Output is correct
7 Incorrect 236 ms 92988 KB Unexpected end of file - int32 expected
8 Incorrect 240 ms 93312 KB Unexpected end of file - int32 expected
9 Correct 231 ms 88980 KB Output is correct
10 Correct 169 ms 65984 KB Output is correct
11 Correct 202 ms 72756 KB Output is correct
12 Incorrect 26 ms 47296 KB Unexpected end of file - int32 expected
13 Incorrect 26 ms 47268 KB Unexpected end of file - int32 expected
14 Incorrect 25 ms 47316 KB Unexpected end of file - int32 expected