Submission #74176

# Submission time Handle Problem Language Result Execution time Memory
74176 2018-08-30T11:16:44 Z jiaqing23 Zalmoxis (BOI18_zalmoxis) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<ll> vi;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
typedef pair<int,pair<int,int> > tri;
 
int n, k;
int a[1000050];
set<pi> s;
//set<int> pos;
multiset<int> s2;
vector<int> add[1000050];
int addnum = 0;
int need;
int cnt[35];
int nxt[1000050];
 
void split(int k){
    for(int i = 0; i < 35; i++) cnt[i] = 0;
    cnt[k] = 1;
    while(need>0){
        if(k==1) break;
        if(cnt[k]){
            cnt[k]--;
            cnt[k-1] +=2;
            need--;
        }
        else k--;
 
    }
    for(int i = 1; i <= 30; i++){
        for(int j = 0; j < cnt[i]; j++){
            cout << i << ' ';
        }
    }
}
 
int main()
{
	//ios_base::sync_with_stdio(0); cin.tie(0);
 
	cin >> n >> k;
	for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        s.insert(mp(a[i],i));
       //pos.insert(i);
        if(i!=n-1) nxt[i] = i+1;
        else nxt[i] = -1;
	}
 
	while(1){
        auto it = s.begin();
        pi p = *it;
        //cout<<p.fi<<endl;
        if(s.size()==1){
            if(p.fi==30) break;
            else{
                for(int i = p.fi; i <= 29; i++){
                    add[p.se].pb(i);
                    addnum++;
                }
                s.erase(it);
                s.insert(mp(30,p.se));
            }
        }
        else{
            auto it2 = ++it;
            pi next = *it2;
            it--;
            if(p.fi == next.fi && nxt[p.se] == next.se){
                s.erase(it2);
              //  pos.erase(next.se);
                nxt[p.se] = nxt[next.se];
                s.erase(it);
                s.insert(mp(p.fi+1, p.se));
            }
            else{
                add[p.se].pb(p.fi);
                addnum ++;
                s.erase(it);
                s.insert(mp(p.fi+1, p.se));
            }
        }
 
 
	}
 
    need = k - addnum;
    for(int i = 0; i < n; i++){
        for(int j = add[i].size()-1; j >= 0; j--){
            if(need > 0) split(add[i][j]);
            else
                printf("%d ",add[i][j]);
        }
        printf("%d ",a[i]);
       // cout<<endl;
    }
 
	return 0;
}

Compilation message

zalmoxis.cpp:38:2: error: stray '\302' in program
     while(need>0){
  ^
zalmoxis.cpp:38:3: error: stray '\240' in program
     while(need>0){
   ^
zalmoxis.cpp:38:5: error: stray '\302' in program
     while(need>0){
     ^
zalmoxis.cpp:38:6: error: stray '\240' in program
     while(need>0){
      ^
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
         ~~~~~^~~~~~~~~~~~