답안 #64740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64740 2018-08-05T13:36:22 Z Good Zalmoxis (BOI18_zalmoxis) C++11
30 / 100
374 ms 36572 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];
int P[Maxn];

vector <int> v, v1, 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);

	int mn = 40;
	for (int i = 1; i <= n; i++)
		scanf ("%d", A + i);
	
	for (int i = 1; i <= n; i++) {
		int x = A[i];
		while (v.size() > 0 and x == v.back()) {
			v.ppb();
			x++;
		}
		
		v.pb (x);
		P[v.size() - 1] = i;
	}	
	
	for (auto i: v)
		mn = min (i, mn);	
	
	ll x = 0;
	for (auto i: v) {
		ll y = i - mn;
		x += 1 << y;
	}
		
	x = (1 << (30 - mn)) - x;
	cnt[mn] = x;
	
	int sm = 0;
	for (int i = mn; i <= 30; i++) {
		cnt[i + 1] += cnt[i] / 2;
		cnt[i] %= 2;
		sm += cnt[i];
	}
			
	for (int i = mn; i < 30; i++) {
		for (int j = 0; j < v.size(); j++) {			
			if (v[j] == i)						
				v1.pb (v[j]), E[P[j]].pb (v[j]);
				
			int e = v[j];
			while (v1.size() > 0 and e == v1.back())
				e ++, v1.ppb();
			
			v1.pb (e);
			P[v1.size() - 1] = P[j];
		}
		
		v = v1;
		v1.clear();
	}
	
	for (int i = 1; i <= n; i++) {
		printf ("%d ", A[i]);
		
		for (auto j: E[i])
			printf ("%d ", j);
	}	
	return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:71:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < v.size(); j++) {   
                   ~~^~~~~~~~~~
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:38:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d", A + i);
   ~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 296 ms 29692 KB Output is correct
2 Correct 289 ms 29932 KB Output is correct
3 Correct 374 ms 29932 KB Output is correct
4 Correct 294 ms 30152 KB Output is correct
5 Correct 274 ms 30152 KB Output is correct
6 Correct 248 ms 30152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 279 ms 30152 KB Unexpected end of file - int32 expected
2 Incorrect 277 ms 30308 KB Expected EOF
3 Incorrect 310 ms 30576 KB Expected EOF
4 Incorrect 351 ms 30576 KB Unexpected end of file - int32 expected
5 Incorrect 303 ms 30576 KB Unexpected end of file - int32 expected
6 Incorrect 321 ms 30576 KB Unexpected end of file - int32 expected
7 Incorrect 241 ms 30576 KB Unexpected end of file - int32 expected
8 Incorrect 374 ms 30576 KB Unexpected end of file - int32 expected
9 Incorrect 277 ms 36572 KB Expected EOF
10 Incorrect 138 ms 36572 KB Unexpected end of file - int32 expected
11 Incorrect 217 ms 36572 KB Unexpected end of file - int32 expected
12 Incorrect 24 ms 36572 KB Unexpected end of file - int32 expected
13 Incorrect 21 ms 36572 KB Unexpected end of file - int32 expected
14 Incorrect 23 ms 36572 KB Unexpected end of file - int32 expected