UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#210229#3776. 可爱小树cql100184ms5812kbC++11622b2024-08-06 09:29:052024-08-06 12:19:23

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
	int n, l; cin >> n;
	vector<pair<int, int>> v(n);
	vector<int> res(n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &v[i].first);
		v[i].second = i;
	}
	sort(v.begin(), v.end());
	res[v[n - 1].second] = 0;
	l = n - 1;
	for (int i = n - 2; i >= 0; i--) {
		if (l < n - 1 && v[l].first == v[l + 1].first)
			l++;
		if (v[i].first < v[i + 1].first)
			l = i + 1;
		res[v[i].second] = v[l].second + 1;
	}
	for (int i = 0; i < n; i++)
		cout << res[i] << ' ';
	return 0;
}
// 0 0 1 2 3
// 2 1 1 0 0
// 0 0 0 0 0

详细

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

Test #1:

score: 10
Accepted
time: 0ms
memory: 1280kb

input:

11
0 1 2 3 4 5 6 7 8 9 10

output:

2 3 4 5 6 7 8 9 10 11 0 

result:

ok Congrats, all the answers are valid.

Test #2:

score: 10
Accepted
time: 0ms
memory: 1284kb

input:

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

output:

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

result:

ok Congrats, all the answers are valid.

Test #3:

score: 10
Accepted
time: 0ms
memory: 1300kb

input:

999
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 3...

output:

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

result:

ok Congrats, all the answers are valid.

Test #4:

score: 10
Accepted
time: 0ms
memory: 1280kb

input:

94
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0...

output:

40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 4...

result:

ok Congrats, all the answers are valid.

Test #5:

score: 10
Accepted
time: 37ms
memory: 5812kb

input:

199992
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 ...

result:

ok Congrats, all the answers are valid.

Test #6:

score: 10
Accepted
time: 0ms
memory: 1404kb

input:

4995
3598 702 2058 315 810 3553 2897 812 3108 395 847 1936 1347 3112 431 3546 1213 542 1674 253 1115...

output:

2636 4399 802 3417 4644 2412 919 4767 3271 4008 3783 1193 1481 4128 3032 2471 4485 2751 3933 4718 38...

result:

ok Congrats, all the answers are valid.

Test #7:

score: 10
Accepted
time: 57ms
memory: 5812kb

input:

199995
73857 87223 9127 55593 79096 29256 65222 68517 94617 24795 59461 64589 29004 18418 90863 2720...

output:

192292 109955 185423 12771 114466 66995 87219 130949 94970 120845 128113 118090 146053 183349 170722...

result:

ok Congrats, all the answers are valid.

Test #8:

score: 10
Accepted
time: 27ms
memory: 3440kb

input:

99993
53106 38032 8196 3041 65305 15449 52233 7617 6543 21376 61968 23032 33290 58751 14610 5174 727...

output:

76798 83725 30503 88585 32587 82824 50181 77677 96022 64015 2598 96563 65147 31146 98480 46106 96825...

result:

ok Congrats, all the answers are valid.

Test #9:

score: 10
Accepted
time: 43ms
memory: 3436kb

input:

99998
37562 29469 5433 30712 31359 56582 18039 29636 52142 9885 6407 11263 47450 45300 34612 31399 1...

output:

93408 98273 63343 95415 62161 87736 65607 94123 12900 59985 33568 64296 66778 50524 97104 23612 5304...

result:

ok Congrats, all the answers are valid.

Test #10:

score: 10
Accepted
time: 20ms
memory: 2380kb

input:

49994
43071 40142 37165 42661 2289 25114 35938 2629 12203 3996 18305 7586 22898 12631 36647 17835 39...

output:

4679 37096 20436 16172 11938 34949 22293 47184 2704 20885 45020 28352 46357 23659 43770 49003 13544 ...

result:

ok Congrats, all the answers are valid.

Extra Test:

score: 0
Extra Test Passed