Submission #66332

# Submission time Handle Problem Language Result Execution time Memory
66332 2018-08-10T08:55:11 Z Good Zalmoxis (BOI18_zalmoxis) C++11
30 / 100
382 ms 63752 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ff first
#define ss second
#define Maxn 1000003
#define ll long long
#define pb push_back
#define Inf 1000000009
#define ppb() pop_back()
#define pii pair <int , int>
#define mid(x, y) (x + y) / 2
#define all(x) x.begin(),x.end()
#define llInf 1000000000000000009
#define tr(i, c) for(__typeof(c).begin() i = (c).begin() ; i != (c).end() ; i++)
using namespace std;
using namespace __gnu_pbds;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> order;

int n, k;
ll cnt[33];
int A[Maxn];

deque <int> dq;
vector <int> E[Maxn];

int main () {
	//freopen ("file.in", "r", stdin);
	//freopen ("file.out", "w", stdout);
	
 	//srand ((unsigned) time ( NULL ));
	//int randomNumber = rand() % 10 + 1;

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

	for (int i = 1; i <= n; i++)
		scanf ("%d", A + i);
	
	dq.push_front (30);
	
	int p = 0;
	int id = 1;
	
	while(id <= n) {
        int v = dq.front();
		dq.pop_front();
		
		if (v == A[id])
            id ++;
            
        else if (v < A[id])
              E[id - 1].pb (v), p ++;
        
		else {
              v --;
              if (v < 0) continue;
              dq.push_front (v);
              dq.push_front (v);
        }
        
    }
	
	for (int i = 0; i < dq.size(); i ++)
        E[id - 1].pb (dq[i]);
	
	p += dq.size();
	k -= p;	
			
	for (int i = 1; i <= n; i++) {
		printf ("%d ", A[i]);
		
		for (auto l: E[i]) {
			memset (cnt, 0, sizeof (cnt));
			
			cnt[l] = 1;
			for (int j = l; j >= 1; j--) {
				if (k > 0 and cnt[j] > 0)
					k --, cnt[j] --, cnt[j - 1] += 2;
					
				for (int o = 1; o <= cnt[j]; o++)
					printf ("%d ", j);
			}
			
			for (int j = 1; j <= cnt[0]; j++)
				printf ("%d ", j);		
		}	
	}	
	
	return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:63:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < dq.size(); i ++)
                  ~~^~~~~~~~~~~
zalmoxis.cpp:34:8: 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:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d", A + i);
   ~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 256 ms 31864 KB Output is correct
2 Correct 228 ms 34176 KB Output is correct
3 Correct 221 ms 36116 KB Output is correct
4 Correct 382 ms 38204 KB Output is correct
5 Correct 260 ms 40300 KB Output is correct
6 Correct 255 ms 42200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 333 ms 44416 KB not a zalsequence
2 Incorrect 254 ms 46432 KB not a zalsequence
3 Incorrect 305 ms 48528 KB not a zalsequence
4 Incorrect 236 ms 50580 KB not a zalsequence
5 Incorrect 276 ms 52784 KB not a zalsequence
6 Incorrect 287 ms 54864 KB not a zalsequence
7 Incorrect 269 ms 56796 KB Unexpected end of file - int32 expected
8 Incorrect 265 ms 58976 KB Unexpected end of file - int32 expected
9 Incorrect 275 ms 63204 KB not a zalsequence
10 Incorrect 244 ms 63204 KB not a zalsequence
11 Incorrect 246 ms 63752 KB not a zalsequence
12 Incorrect 26 ms 63752 KB Unexpected end of file - int32 expected
13 Incorrect 28 ms 63752 KB Unexpected end of file - int32 expected
14 Incorrect 25 ms 63752 KB Unexpected end of file - int32 expected