Submission #103737

#TimeUsernameProblemLanguageResultExecution timeMemory
103737ekremZalmoxis (BOI18_zalmoxis)C++98
0 / 100
411 ms30568 KiB
#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 (stderr)

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);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...