답안 #103737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103737 2019-04-02T11:00:18 Z ekrem Zalmoxis (BOI18_zalmoxis) C++
0 / 100
411 ms 30568 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, k, m[N], a[N], b[N], bas[N], son[N], u[N], g[35][N];
ii ans;

void sirala(int j){
	for(int i = 1; i <= m[j]; i++)
		u[g[j][i]]++;

	m[j] = 0;
	for(int i = 1; i <= n; i++)
		while(u[i]){
			g[j][++m[j]] = i;
			u[i]--;
		}

}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&n ,&k);
	for(int i = 1; i <= n; i++){
		scanf("%d",a + i);
		g[a[i]][++m[a[i]]] = i;
		bas[i] = i;
		son[i] = i;
	}
	for(int i = 1; i <= 29; i++){

		sirala(i);

		// cout << i << " -> ";
		// for(int j = 1; j <= m[i]; j++)
		// 	cout << g[i][j] << " ";
		// cout << endl;

		for(int j = 1; j <= m[i]; j++)
			if(j < m[i] and son[g[i][j]] + 1 == bas[g[i][j + 1]]){
				// cout << " buldum " << g[i][j] << endl;
				g[i + 1][++m[i + 1]] = (g[i][j + 1]);
				bas[g[i][j + 1]] = bas[g[i][j]];
				j++;
			} else{
				// cout << "EKLEEE" << endl;
				ans = mp(g[i][j], i);
				g[i + 1][++m[i + 1]] = (g[i][j]);
			}
	}
	for(int i = 1; i <= n; i++){
		printf("%d ", a[i]);
		if(i == ans.st)
			printf("%d ", ans.nd);
	}
	return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:32: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:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",a + i);
   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 336 ms 30136 KB not a zalsequence
2 Incorrect 318 ms 29560 KB not a zalsequence
3 Incorrect 283 ms 29688 KB not a zalsequence
4 Incorrect 344 ms 29736 KB not a zalsequence
5 Incorrect 335 ms 29584 KB not a zalsequence
6 Incorrect 331 ms 30568 KB not a zalsequence
# 결과 실행 시간 메모리 Grader output
1 Incorrect 411 ms 29980 KB Unexpected end of file - int32 expected
2 Incorrect 295 ms 30328 KB Unexpected end of file - int32 expected
3 Incorrect 315 ms 29436 KB Unexpected end of file - int32 expected
4 Incorrect 363 ms 29432 KB Unexpected end of file - int32 expected
5 Incorrect 393 ms 29676 KB Unexpected end of file - int32 expected
6 Incorrect 345 ms 30020 KB Unexpected end of file - int32 expected
7 Incorrect 330 ms 29560 KB Unexpected end of file - int32 expected
8 Incorrect 352 ms 29176 KB Unexpected end of file - int32 expected
9 Incorrect 311 ms 24876 KB Unexpected end of file - int32 expected
10 Incorrect 95 ms 10232 KB Unexpected end of file - int32 expected
11 Incorrect 221 ms 16780 KB Unexpected end of file - int32 expected
12 Incorrect 2 ms 640 KB Unexpected end of file - int32 expected
13 Incorrect 3 ms 640 KB Unexpected end of file - int32 expected
14 Incorrect 3 ms 640 KB Unexpected end of file - int32 expected