Submission #60005

# Submission time Handle Problem Language Result Execution time Memory
60005 2018-07-23T12:03:40 Z Kerim Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
223 ms 12892 KB
#include "bits/stdc++.h"
#define MAXN 1000009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
stack<int>st;
int arr[MAXN];
void relax(){
	while(!st.empty()){
		int a=st.top();st.pop();
		if(st.empty()){
			st.push(a);
			break;
		}
		int b=st.top();
		if(a==b){
			st.pop();
			st.push(a+1);
		}
		else{
			st.push(a);	
			break;
		}
	}
}
void solve(int x,int y){
	vector<int>v,g;
	v.pb(x);
	while(y){
		if(!v.size()){
			swap(v,g);
			g.clear();
		}
		assert(v.back()>=1);
		g.pb(v.back()-1);
		g.pb(v.back()-1);
		v.ppb();y--;
	}
	tr(it,v)
		printf("%d ",*it);
	tr(it,g)
		printf("%d ",*it);
}
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
		scanf("%d",&arr[i]);
	st.push(INF);
	vector<PII>ans;
	for(int i=1;i<=n;i++){
		while(st.top()<arr[i]){
			int tmp=st.top();
			st.pop();
			st.push(tmp+1);
			ans.pb(mp(tmp,1));k--;
			relax();
		}
		ans.pb(mp(arr[i],0));
		st.push(arr[i]);
		relax();
	}	
	while(!st.empty()){
		int nd=st.top();st.pop();
		if(nd==30)
			break;
		ans.pb(mp(nd,1));k--;	
		st.push(nd+1);
		relax();
	}
	assert(k>=0);
	puts("-1");
	exit(0);
	tr(it,ans){
		if(it->ss==0)
			printf("%d ",it->ff);
		else{
			if((1<<it->ff)<=k){
				k-=(1<<it->ff);
				for(int j=0;j<(1<<it->ff);j++)
					printf("0 ");
			}
			else
				solve(it->ff,k),k=0;
		}	
	}puts("");
	return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:61:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
zalmoxis.cpp:63:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&arr[i]);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 165 ms 12508 KB Unexpected end of file - int32 expected
2 Incorrect 158 ms 12604 KB Unexpected end of file - int32 expected
3 Incorrect 205 ms 12620 KB Unexpected end of file - int32 expected
4 Incorrect 180 ms 12652 KB Unexpected end of file - int32 expected
5 Incorrect 193 ms 12692 KB Unexpected end of file - int32 expected
6 Incorrect 181 ms 12692 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 12692 KB Unexpected end of file - int32 expected
2 Incorrect 165 ms 12748 KB Unexpected end of file - int32 expected
3 Incorrect 140 ms 12748 KB Unexpected end of file - int32 expected
4 Incorrect 193 ms 12748 KB Unexpected end of file - int32 expected
5 Incorrect 163 ms 12892 KB Unexpected end of file - int32 expected
6 Incorrect 223 ms 12892 KB Unexpected end of file - int32 expected
7 Incorrect 151 ms 12892 KB Unexpected end of file - int32 expected
8 Incorrect 179 ms 12892 KB Unexpected end of file - int32 expected
9 Incorrect 135 ms 12892 KB Unexpected end of file - int32 expected
10 Incorrect 64 ms 12892 KB Unexpected end of file - int32 expected
11 Incorrect 89 ms 12892 KB Unexpected end of file - int32 expected
12 Incorrect 4 ms 12892 KB Unexpected end of file - int32 expected
13 Incorrect 2 ms 12892 KB Unexpected end of file - int32 expected
14 Incorrect 3 ms 12892 KB Unexpected end of file - int32 expected