답안 #103736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103736 2019-04-02T10:50:40 Z ekrem Zalmoxis (BOI18_zalmoxis) C++
0 / 100
1000 ms 86288 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, a[N], b[N], bas[N], son[N];
ii ans;
set < ii > s, q;
set < ii > :: iterator it;
vector < int > g[N];

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]].pb(i);
		bas[i] = i;
		son[i] = i;
	}
	for(int i = 1; i <= 30; i++){
		sort(g[i].begin(), g[i].end());
		for(int j = 0; j < g[i].size(); j++)
			if(j < (int)g[i].size() - 1 and son[g[i][j]] == bas[g[i][j + 1]]){
				g[i + 1].pb(g[i][j + 1]);
				bas[g[i][j + 1]] = bas[g[i][j]];
			} else{
				ans = mp(g[i][j], a[g[i][j]]);
				g[i + 1].pb(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:31:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < g[i].size(); j++)
                  ~~^~~~~~~~~~~~~
zalmoxis.cpp:22: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:24: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 Execution timed out 1081 ms 81076 KB Time limit exceeded
2 Execution timed out 1075 ms 78536 KB Time limit exceeded
3 Execution timed out 1090 ms 86288 KB Time limit exceeded
4 Execution timed out 1083 ms 81408 KB Time limit exceeded
5 Execution timed out 1079 ms 78260 KB Time limit exceeded
6 Execution timed out 1076 ms 82508 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 75256 KB Time limit exceeded
2 Execution timed out 1072 ms 80176 KB Time limit exceeded
3 Execution timed out 1070 ms 79576 KB Time limit exceeded
4 Execution timed out 1083 ms 82800 KB Time limit exceeded
5 Execution timed out 1082 ms 84228 KB Time limit exceeded
6 Execution timed out 1091 ms 84360 KB Time limit exceeded
7 Execution timed out 1085 ms 81800 KB Time limit exceeded
8 Execution timed out 1069 ms 83060 KB Time limit exceeded
9 Execution timed out 1088 ms 76164 KB Time limit exceeded
10 Incorrect 504 ms 55424 KB Unexpected end of file - int32 expected
11 Incorrect 914 ms 75952 KB Unexpected end of file - int32 expected
12 Incorrect 24 ms 23808 KB Unexpected end of file - int32 expected
13 Incorrect 28 ms 23800 KB Unexpected end of file - int32 expected
14 Incorrect 22 ms 23808 KB Unexpected end of file - int32 expected