답안 #491388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491388 2021-12-01T23:11:08 Z Yazan_Alattar Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
428 ms 58444 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <utility>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 1000007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int n, k, a[M];
vector <int> pos[M];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    vector < pair <int,int> > v(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        v[i] = {a[i], i};
    }
    for(int j = 1; j < 30; ++j){
        vector < pair <int,int> > nw;
        int cur = 0;
        for(int i = 0; i < v.size(); ++i){
            if(cur){
                if(nw.back().F != v[i].F){
                    int last = nw.back().S;
                    pos[nw.back().S].pb(j);
                    nw.pop_back();
                    nw.pb({j + 1, last});
                    nw.pb(v[i]);
                    --k;
                }
                else{
                    nw.pop_back();
                    nw.pb({j + 1, v[i].S});
                }
                cur = 0;
            }
            else{
                nw.pb(v[i]);
                cur += (v[i].F == j);
            }
        }
        if(cur){
            --k;
            nw.pop_back();
            nw.pb({j + 1, v.back().S});
            pos[nw.back().S].pb(j);
        }
        v = nw;
    }
    int cur = 0;
    for(int i = 0; i < n; ++i){
        cout << a[i] << " ";
        for(auto j : pos[i]){
            if(k > 0){
                cout << j - 1 << " ";
                --k;
                int cur = j - 1;
                while(k-- && cur > 1) cout << --cur << " ";
                cout << cur << " ";
            }
            else cout << j << " ";
        }
    }
    cout << endl;
    return 0;
}
// Don't forget special cases. (n = 1?)
// Look for the constraints. (Runtime array? overflow?)

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int i = 0; i < v.size(); ++i){
      |                        ~~^~~~~~~~~~
zalmoxis.cpp:70:9: warning: unused variable 'cur' [-Wunused-variable]
   70 |     int cur = 0;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 381 ms 57044 KB Expected EOF
2 Incorrect 365 ms 56336 KB Expected EOF
3 Incorrect 371 ms 56820 KB Expected EOF
4 Incorrect 373 ms 56724 KB Expected EOF
5 Incorrect 379 ms 56628 KB Expected EOF
6 Incorrect 409 ms 58444 KB Expected EOF
# 결과 실행 시간 메모리 Grader output
1 Incorrect 387 ms 56860 KB Expected EOF
2 Incorrect 428 ms 57412 KB Expected EOF
3 Incorrect 351 ms 56412 KB Expected EOF
4 Incorrect 350 ms 56372 KB Expected EOF
5 Incorrect 392 ms 56720 KB Expected EOF
6 Incorrect 398 ms 56932 KB Expected EOF
7 Incorrect 359 ms 56640 KB Expected EOF
8 Incorrect 340 ms 56196 KB Expected EOF
9 Incorrect 335 ms 52840 KB Expected EOF
10 Incorrect 161 ms 36656 KB Unexpected end of file - int32 expected
11 Incorrect 242 ms 42576 KB Expected EOF
12 Incorrect 13 ms 23716 KB Unexpected end of file - int32 expected
13 Incorrect 14 ms 23756 KB Unexpected end of file - int32 expected
14 Incorrect 12 ms 23756 KB Unexpected end of file - int32 expected