QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#773447 | #9790. Make Swamp Great Again | ucup-team4454# | WA | 14ms | 2756kb | C++14 | 1.1kb | 2024-11-23 08:52:13 | 2024-11-23 08:52:14 |
Judging History
answer
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+100;
int n,t[N+10],c[N+10],ans[N+10];
int id(int x)
{
if(x==n+1) return 1;
if(x==0) return n;
return x;
}
int main()
{
// freopen("J.in","r",stdin);
scanf("%d",&n);
for(int i=1;i<=N;i++)
ans[i]=N;
for(int i=1;i<=n;i++)
scanf("%d",&t[i]),c[t[i]]++;
for(int i=1;i<=n;i++)
{
if(min(t[id(i-1)],min(t[i],t[id(i+1)]))==t[i]||max(t[id(i-1)],max(t[i],t[id(i+1)]))==t[i])
ans[t[i]]=min(ans[t[i]],n-c[t[i]]);
else
ans[t[i]]=min(ans[t[i]],n-c[t[i]]+1);
if(min(t[id(i+2)],min(t[i],t[id(i+1)]))==t[i]||max(t[id(i+2)],max(t[i],t[id(i+1)]))==t[i])
ans[t[i]]=min(ans[t[i]],n-c[t[i]]);
else
ans[t[i]]=min(ans[t[i]],n-c[t[i]]+1);
if(min(t[id(i-1)],min(t[i],t[id(i-2)]))==t[i]||max(t[id(i-1)],max(t[i],t[id(i-2)]))==t[i])
ans[t[i]]=min(ans[t[i]],n-c[t[i]]);
else
ans[t[i]]=min(ans[t[i]],n-c[t[i]]+1);
}
for(int i=1;i<=n;i++)
printf("%d ",ans[t[i]]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 2004kb
input:
6 4 7 47 4 77 47
output:
4 6 4 4 5 4
result:
ok single line: '4 6 4 4 5 4 '
Test #2:
score: 0
Accepted
time: 0ms
memory: 1992kb
input:
6 4 7 47 4 77 47
output:
4 6 4 4 5 4
result:
ok single line: '4 6 4 4 5 4 '
Test #3:
score: 0
Accepted
time: 4ms
memory: 2456kb
input:
34282 90425 22450 88504 38625 50256 24285 29693 59937 55013 65148 74544 79337 84799 18379 96719 45091 46959 34827 91934 5519 57325 75622 98980 11649 42236 14474 44579 97335 71798 95780 52228 34730 42473 53258 62204 12246 15037 67194 47 41533 22010 29201 65866 68828 26827 16763 76098 73625 5875 92559...
output:
34281 34281 34281 34281 34281 34280 34281 34281 34281 34281 34281 34281 34281 34280 34281 34281 34281 34281 34281 34281 34281 34281 34280 34281 34281 34281 34281 34280 34281 34279 34281 34281 34281 34281 34281 34281 34282 34281 34281 34281 34281 34281 34280 34281 34281 34280 34281 34280 34281 34279 ...
result:
ok single line: '34281 34281 34281 34281 34281 ... 34280 34281 34281 34281 34281 '
Test #4:
score: 0
Accepted
time: 7ms
memory: 2700kb
input:
92272 71762 25620 15348 35776 16931 76528 9558 49040 89138 57674 33861 40705 81647 81160 54982 56282 86192 69086 78613 83753 91918 9767 22299 44812 2091 70190 23588 60830 54801 12210 51232 33669 67124 11981 62462 85526 36775 48420 26359 71963 12493 43080 56840 28514 64338 86901 10478 61736 64445 428...
output:
92269 92271 92271 92270 92271 92270 92270 92268 92271 92271 92270 92271 92270 92271 92269 92269 92270 92271 92270 92270 92269 92271 92268 92271 92271 92270 92269 92269 92270 92269 92271 92271 92271 92271 92270 92270 92270 92270 92270 92270 92269 92272 92271 92268 92271 92269 92271 92270 92271 92271 ...
result:
ok single line: '92269 92271 92271 92270 92271 ... 92269 92271 92270 92270 92270 '
Test #5:
score: 0
Accepted
time: 3ms
memory: 2204kb
input:
25150 19951 14838 9396 15852 22860 3040 10118 14230 4802 22537 19763 24518 11280 11929 24907 21041 13393 9464 2956 5391 16320 13356 7100 16445 9497 21637 2297 2963 7830 23772 23385 4095 22303 9631 24521 24656 8782 13589 15050 19955 6749 9407 18142 14150 12944 8391 5204 12152 24197 17000 9777 13370 1...
output:
25149 25150 25149 25149 25147 25149 25150 25149 25145 25148 25149 25149 25147 25148 25149 25146 25149 25148 25147 25148 25149 25147 25148 25146 25149 25149 25148 25148 25147 25147 25146 25148 25149 25149 25149 25148 25149 25148 25149 25148 25147 25148 25148 25149 25149 25149 25147 25149 25147 25149 ...
result:
ok single line: '25149 25150 25149 25149 25147 ... 25147 25149 25148 25146 25148 '
Test #6:
score: 0
Accepted
time: 0ms
memory: 2384kb
input:
1438 854 8212 43610 4 126 61917 14 2 19 33266 11780 2644 519 82 202 1 3482 341 753 1684 4 17567 25014 79941 29 212 11 1 3 16120 83009 83 36 140 406 162 19 507 444 50 1 13265 2434 23199 1 8144 98379 7 226 36779 9954 8518 4252 32 5 28092 92 17353 1108 49827 5600 10 68 59 32 7 55777 9204 22 128 1236 14...
output:
1437 1438 1437 1402 1436 1437 1430 1385 1430 1437 1437 1437 1437 1437 1437 1348 1437 1436 1438 1437 1402 1437 1437 1437 1432 1435 1431 1348 1401 1437 1437 1435 1433 1435 1435 1438 1430 1437 1437 1434 1348 1437 1437 1437 1348 1438 1437 1424 1437 1437 1436 1437 1436 1433 1416 1437 1436 1437 1437 1437 ...
result:
ok single line: '1437 1438 1437 1402 1436 1437 ... 1385 1437 1432 1437 1437 1437 '
Test #7:
score: 0
Accepted
time: 14ms
memory: 2756kb
input:
99999 15 7691 8 75 6296 715 41 1 34 120 62992 49157 21 696 214 1 75 1559 911 204 118 103 139 11 89246 894 6 8544 24 1246 7289 4 647 12946 142 19 24 134 3 1417 352 166 28 7588 54525 53 29623 230 201 41386 40 19498 5 72 60659 1 32 7568 106 118 48 642 144 2 20 22 86 604 24729 13933 4 3032 182 28 1 3229...
output:
99437 99996 98981 99883 99996 99986 99798 94094 99738 99926 99998 99998 99593 99988 99957 94094 99883 99992 99989 99960 99937 99911 99926 99225 99998 99987 98682 99998 99646 99989 99997 97979 99984 99997 99929 99503 99646 99928 97529 99993 99975 99945 99704 99998 99998 99843 99998 99964 99948 99998 ...
result:
ok single line: '99437 99996 98981 99883 99996 ... 99661 99997 99955 99995 99952 '
Test #8:
score: 0
Accepted
time: 0ms
memory: 2436kb
input:
17462 9732 40 232 703 1537 12 1 3759 1 3 25944 2 116 13674 3002 5830 10573 17 14767 32469 7 4907 4281 1 4792 269 2 3 10 61981 480 4 8951 1 2 129 121 17263 114 91977 70515 1499 21 43 26 2825 37571 898 234 7 68746 134 417 1284 6 52007 2010 9906 2391 81 954 77751 18 1 23617 12 194 777 205 108 16078 88 ...
output:
17459 17430 17453 17458 17460 17329 16418 17461 16418 16999 17461 16853 17446 17461 17461 17462 17461 17388 17461 17461 17269 17461 17461 16418 17461 17456 16853 16999 17351 17461 17459 17118 17461 16418 16853 17450 17454 17461 17451 17461 17461 17459 17389 17423 17407 17461 17461 17458 17456 17269 ...
result:
ok single line: '17459 17430 17453 17458 17460 ... 17276 17456 17460 17461 16418 '
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 2044kb
input:
8 7 15 1 6 221 60818 38263 2
output:
7 7 7 7 7 7 7 7
result:
wrong answer 1st lines differ - expected: '8 7 7 7 7 7 7 7', found: '7 7 7 7 7 7 7 7 '