답안 #63025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
63025 2018-07-31T10:39:10 Z hamzqq9 Zalmoxis (BOI18_zalmoxis) C++14
80 / 100
328 ms 14688 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define sz(x) (x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000500000
#define MOD 1000000007
#define N 305
#define LOG 20
using namespace std;

int n,k,x;
stack<int> s;
vector<int> ans,cev,seq;
int rem;

void solve(int x) {

	if(x==0 || rem==0) {

		cev.pb(x);

		return ;	
	
	}

	rem--;

	solve(x-1);
	solve(x-1);

}

int main() {

//	freopen("input.txt","r",stdin);

	scanf("%d %d",&n,&k);

	for(int i=1;i<=n+1;i++) {

		if(i==n+1 && sz(ans)==n+k) break ;

		if(i!=n+1) {scanf("%d",&x);seq.pb(x);}
		else x=inf;

		while((i!=n+1)?(sz(s) && s.top()<x):(sz(s)>1)) {

			int val=s.top();

			ans.pb(val);

			while(sz(s) && s.top()==val) {

				s.pop();

				val++;

			}

			s.push(val);

		}

		if(i!=n+1) {

			int tut=x;

			while(sz(s) && s.top()==tut) {

				s.pop();

				tut++;

			}

			s.push(tut);

			ans.pb(x);

		}

	}

	rem=n+k-sz(ans);

	int cur=0;

	for(int i=0;i<sz(ans);i++) {

		if(cur<sz(seq) && seq[cur]==ans[i]) {

			cev.pb(ans[i]);

			cur++;

		}
		else {

			solve(ans[i]);

		}

	}

	int val=s.top();

	while(rem>0) {

		solve(val);

		val++;

	}

	for(auto x:cev) printf("%d ",x);

}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:53:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i==n+1 && sz(ans)==n+k) break ;
                       ^
zalmoxis.cpp:100:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<sz(ans);i++) {
               ^
zalmoxis.cpp:102:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(cur<sz(seq) && seq[cur]==ans[i]) {
         ^
zalmoxis.cpp:49:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
zalmoxis.cpp:55:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   if(i!=n+1) {scanf("%d",&x);seq.pb(x);}
               ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 220 ms 14348 KB Output is correct
2 Correct 294 ms 14452 KB Output is correct
3 Correct 228 ms 14544 KB Output is correct
4 Correct 226 ms 14572 KB Output is correct
5 Correct 328 ms 14572 KB Output is correct
6 Correct 248 ms 14572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 258 ms 14572 KB Output is correct
2 Correct 236 ms 14572 KB Output is correct
3 Correct 251 ms 14572 KB Output is correct
4 Correct 228 ms 14684 KB Output is correct
5 Correct 290 ms 14688 KB Output is correct
6 Correct 242 ms 14688 KB Output is correct
7 Correct 305 ms 14688 KB Output is correct
8 Correct 274 ms 14688 KB Output is correct
9 Correct 230 ms 14688 KB Output is correct
10 Incorrect 158 ms 14688 KB not a zalsequence
11 Correct 198 ms 14688 KB Output is correct
12 Incorrect 96 ms 14688 KB Expected EOF
13 Incorrect 95 ms 14688 KB Expected EOF
14 Incorrect 92 ms 14688 KB Expected EOF