Submission #856092

# Submission time Handle Problem Language Result Execution time Memory
856092 2023-10-02T16:33:54 Z Benmath Zalmoxis (BOI18_zalmoxis) C++14
35 / 100
550 ms 139480 KB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
int niz[1000001];
int n;
int k;
int vis[1000001];
vector<int>solve(int x, int y){
    
    if (y == 1){
        vector<int>ans;
        ans.push_back(x);
        return ans;
    }else if(y == 2){
        vector<int>ans;
        ans.push_back(x-1);
        ans.push_back(x-1);
        return ans;
    }else{
        if(x == 1){
            vector<int>ans;
            ans.push_back(0);
            ans.push_back(0);
            return ans;
        }
        vector<int> ro1 = solve(x - 1, y - 1);
        vector<int> ro2 = solve(x - 1, y - ro1.size());
        for(int i = 0; i < ro2.size();i++){
            ro1.push_back(ro2[i]);
        }
        return ro1;
    }
}
using pii = pair<int,pair<int,int>>;
int main()
{
    cin >> n >> k;
    vector<int>v[n];
    priority_queue<pii, vector<pii> , greater<pii> > pq;
    for(int i = 0; i < n; i++){
        cin >> niz[i];
        pq.push({niz[i],{i,i}});
    }
    int t1 = 0;
    while(!pq.empty() and t1 < k){
        pii a = pq.top();
        pq.pop();
        if(a.first < 30){
        if(pq.empty()){
            v[a.second.second].push_back(a.first);
            pq.push({a.first + 1, {a.second.first, a.second.second}});
            t1++;
        }else{
            pii b = pq.top();
            pq.pop();
            if(a.first != b.first){
                v[a.second.second].push_back(a.first);
                pq.push({a.first + 1, {a.second.first, a.second.second}});
                pq.push({b.first, {b.second.first,b.second.second}});
                t1++;
            }else{
                int prvi = a.second.second + 1;
                int drugi = b.second.first;
                if(prvi == drugi){
                    pq.push({a.first + 1,{a.second.first,b.second.second}});
                }else{
                    v[a.second.second].push_back(a.first);
                    pq.push({a.first + 1, {a.second.first, a.second.second}});
                    t1++;
                }
            }
        }
        }
    }
    k = k - t1;
    
    for(int i = 0; i < n; i++){
        cout << niz[i] << " ";
        for(int j = 0;j < v[i].size(); j++){
            
            vector<int> ro = solve(v[i][j], k + 1);
            for(int t = 0; t < ro.size(); t++){
                cout<<ro[t]<<" ";
            }
            int velicina = ro.size();
            k = k - (velicina - 1);
        }
    }
}

Compilation message

zalmoxis.cpp: In function 'std::vector<int> solve(int, int)':
zalmoxis.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i = 0; i < ro2.size();i++){
      |                        ~~^~~~~~~~~~~~
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:87:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |         for(int j = 0;j < v[i].size(); j++){
      |                       ~~^~~~~~~~~~~~~
zalmoxis.cpp:90:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |             for(int t = 0; t < ro.size(); t++){
      |                            ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 480 ms 43444 KB Output is correct
2 Correct 550 ms 43840 KB Output is correct
3 Correct 507 ms 43240 KB Output is correct
4 Correct 513 ms 43948 KB Output is correct
5 Correct 497 ms 43436 KB Output is correct
6 Correct 504 ms 43380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 508 ms 43496 KB not a zalsequence
2 Incorrect 217 ms 43308 KB not a zalsequence
3 Incorrect 207 ms 43560 KB not a zalsequence
4 Incorrect 468 ms 43492 KB not a zalsequence
5 Incorrect 463 ms 43260 KB not a zalsequence
6 Incorrect 478 ms 43608 KB not a zalsequence
7 Incorrect 548 ms 43416 KB not a zalsequence
8 Incorrect 491 ms 43484 KB not a zalsequence
9 Incorrect 328 ms 40692 KB not a zalsequence
10 Incorrect 224 ms 24152 KB not a zalsequence
11 Incorrect 341 ms 30548 KB not a zalsequence
12 Incorrect 106 ms 9096 KB not a zalsequence
13 Incorrect 159 ms 139480 KB not a zalsequence
14 Correct 100 ms 9116 KB Output is correct