UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212299#3813. T3sublimetext0184ms2828kbC++1.4kb2024-10-13 18:21:572024-10-13 19:39:52

answer

#include <bits/stdc++.h>
using namespace std;
#define LL __int128
#define ll long long
#define uLL __uint128_t
#define ull unsigned long long
#define REP(i, l, r) for(int i = l; i <= r; ++i)
#define PER(i, r, l) for(int i = r; i >= l; --i)
namespace ink {
	const int N = 2e5 + 5;
	int n;
	int a[N];
	int b[5], c[5];
	void CMP(int *A, int *B, int sz) {

		REP(i, 1, sz) {
			if(A[i] != B[i]){
				if(B[i] < A[i]) {
					REP(j, 1, sz) A[j] = B[j];
					return;
				}
				else return;
			}
		}
	}
	void cmp(int *b, int x, int y,int z) {
		c[1] = x, c[2] = y, c[3] = z;
		CMP(b, c, 3);
	}
	int g[N], O[N];
	int main() {
		ios::sync_with_stdio(false);
		cin.tie(0), cout.tie(0);
		cin >> n;
		REP(i, 1, n) cin >> a[i], O[i] = a[i];
		int i = 1;
		for(i = 1; i <= n - 1; i += 2) {
			int x = a[(i + 1) / 2];
			int y = a[i + 1];
			int z = a[i + 2];
			b[1] = x,b[2] = y,b[3] = z;
			cmp(b, z, y, x);
			cmp(b, y, x, z);
			cmp(b, z, x, y);
			// cout << b[1] << ' ' << b[2] << ' ' << b[3] << '\n';
			a[(i + 1) / 2] = b[1], a[i + 1] = b[2], a[i + 2] = b[3];
		}
		for(; i <= n - 1; ++i) {
			if(a[(i + 1) / 2] > a[i + 1])swap(a[(i + 1) / 2], a[i + 1]);
		}
		REP(s, 1, (1 << (n - 1)) - 1) {
			REP(i, 1, n) g[i] = O[i];
			REP(i, 1, n - 1) {
				if(s >> (i - 1) & 1) swap(g[(i + 1) / 2], g[i + 1]);
			}
			CMP(a, g, n);
		}
		REP(i, 1, n) cout << a[i] << " \n"[i == n];
		return 0;
	}
}

signed main() {return ink::main();}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 58ms
memory: 1260kb

input:

20
7 8 4 12 6 19 1 5 16 14 15 20 17 18 9 10 13 11 2 3

output:

4 6 1 5 7 8 9 10 2 3 15 20 17 18 19 12 13 11 16 14

result:

ok 20 numbers

Test #2:

score: -20
Wrong Answer
time: 53ms
memory: 1260kb

input:

20
3 19 17 5 8 14 12 6 15 7 9 4 10 1 20 16 18 13 11 2

output:

3 5 12 6 7 4 1 16 11 0 9 14 10 17 20 19 18 13 15 2

result:

wrong answer 10th numbers differ - expected: '2', found: '0'

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 1264kb

input:

40
19 15 20 27 16 11 34 5 21 6 30 3 40 39 12 2 7 13 1 23 37 32 18 28 25 17 33 31 29 36 4 22 10 35 8 ...

output:

15 16 11 5 6 3 12 2 1 23 18 20 17 29 4 10 7 9 21 0 37 30 32 28 25 40 33 31 34 36 39 19 22 35 8 13 14...

result:

wrong answer 10th numbers differ - expected: '19', found: '23'

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 1276kb

input:

1000
162 57 979 220 75 121 744 693 173 262 399 558 295 360 530 363 977 552 398 101 137 946 85 712 71...

output:

57 75 121 162 220 295 360 363 173 101 85 558 419 242 46 106 238 552 58 262 137 125 35 40 10 318 11 1...

result:

wrong answer 134th numbers differ - expected: '693', found: '778'

Subtask #4:

score: 0
Time Limit Exceeded

Test #16:

score: 0
Time Limit Exceeded

input:

50000
6014 4637 42967 25211 33048 39571 24304 15155 17748 38901 41356 27235 3880 27971 22842 37080 4...

output:


result:


Subtask #5:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 73ms
memory: 2828kb

input:

200000
113806 52130 91627 30299 76623 124589 163145 143300 2089 189894 32321 116979 54734 199544 128...

output:

52130 30299 91627 2089 32321 54734 128524 61701 143300 76623 111794 86779 83115 20542 48297 113806 2...

result:

wrong answer 9th numbers differ - expected: '113806', found: '143300'