답안 #63023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
63023 2018-07-31T10:36:30 Z hamzqq9 Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
1000 ms 263168 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=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 {

			if(rem) 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 Incorrect 396 ms 17384 KB Expected EOF
2 Incorrect 368 ms 17384 KB Expected EOF
3 Incorrect 339 ms 17384 KB Expected EOF
4 Incorrect 306 ms 17384 KB Expected EOF
5 Incorrect 341 ms 17384 KB Expected EOF
6 Incorrect 291 ms 17384 KB Expected EOF
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 41372 KB Time limit exceeded
2 Incorrect 633 ms 41372 KB Expected EOF
3 Incorrect 459 ms 41372 KB Expected EOF
4 Execution timed out 1008 ms 74452 KB Time limit exceeded
5 Incorrect 511 ms 74452 KB Expected EOF
6 Incorrect 722 ms 74452 KB Expected EOF
7 Execution timed out 1058 ms 74452 KB Time limit exceeded
8 Incorrect 394 ms 74452 KB Expected EOF
9 Execution timed out 1064 ms 263168 KB Time limit exceeded
10 Runtime error 152 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
11 Execution timed out 1059 ms 263168 KB Time limit exceeded
12 Runtime error 172 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
13 Runtime error 147 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
14 Runtime error 129 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.