Submission #63021

# Submission time Handle Problem Language Result Execution time Memory
63021 2018-07-31T10:10:08 Z hamzqq9 Zalmoxis (BOI18_zalmoxis) C++14
35 / 100
382 ms 11536 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;

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);
		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);

		}

	}

	assert(sz(ans)<=n+k);

	while(sz(ans)<n+k) {

		int val=s.top();
		s.pop();

		ans.pb(val);

		s.push(val+1);

	}

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

}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:35:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i==n+1 && sz(ans)==n+k) break ;
                       ^
In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from zalmoxis.cpp:1:
zalmoxis.cpp:78:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  assert(sz(ans)<=n+k);
                ^
zalmoxis.cpp:80:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(sz(ans)<n+k) {
               ^
zalmoxis.cpp:31: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:37:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   if(i!=n+1) scanf("%d",&x);
              ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 236 ms 6496 KB Output is correct
2 Correct 382 ms 6660 KB Output is correct
3 Correct 237 ms 6660 KB Output is correct
4 Correct 222 ms 6660 KB Output is correct
5 Correct 264 ms 6768 KB Output is correct
6 Correct 280 ms 6768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 216 ms 6768 KB not a zalsequence
2 Correct 228 ms 6768 KB Output is correct
3 Incorrect 235 ms 6800 KB not a zalsequence
4 Incorrect 263 ms 6800 KB not a zalsequence
5 Incorrect 265 ms 6800 KB not a zalsequence
6 Incorrect 245 ms 6800 KB not a zalsequence
7 Incorrect 229 ms 6800 KB not a zalsequence
8 Incorrect 266 ms 6804 KB not a zalsequence
9 Incorrect 210 ms 6964 KB not a zalsequence
10 Incorrect 158 ms 9356 KB not a zalsequence
11 Incorrect 174 ms 9356 KB not a zalsequence
12 Incorrect 158 ms 11536 KB not a zalsequence
13 Incorrect 135 ms 11536 KB not a zalsequence
14 Incorrect 142 ms 11536 KB not a zalsequence