QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#284374 | #5687. 速战速决 | simonG# | WA | 38ms | 15876kb | C++14 | 1.4kb | 2023-12-16 13:20:55 | 2023-12-16 13:20:55 |
Judging History
answer
#include<bits/stdc++.h>
#define il inline
#define re register
#define ll long long
#define pb push_back
using namespace std;
const int N=1e6+10;
#define gc() getchar()
il int rd(){
int x=0,f=1;
char ch=gc();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=gc();
return x*f;
}
int n;
int a[N],cnt[N],vis[N];
vector<int>q;
int insert(int x){
int p=rand()%n+1;
while(p==q.front()||!cnt[p]||p==x)p=rand()%n+1;
--cnt[p],vis[p]=1,q.pb(p);
return p;
}
void delet(){
++cnt[q.back()],vis[q.back()]=0,q.pop_back();
}
void Main(){
n=rd();
for(int i=1; i<=n; ++i)a[i]=rd();
srand(time(0));
if(n==1){
puts("-1");
return;
}
for(int i=1; i<=n; ++i)++cnt[a[i]];
for(int i=1; i<=n; ++i)cnt[i]=2-cnt[i];
for(int i=1; i<=n; ++i){
if(cnt[i]==2){
printf("%d\n",n);
printf("%d ",i);vis[i]=1;q.pb(i),--cnt[i];
q.pb(a[1]),vis[a[1]]=1;
for(int j=2; j<=n; ++j){
if(vis[a[j]]){
printf("%d ",q.front());
while(!q.empty())delet();
}else{
printf("%d ",insert(a[j]));
}
q.pb(a[j]),vis[a[j]]=1;
}
exit(0);
}
}
printf("%d\n",n+2);
printf("%d ",a[1]);
for(int i=2; i<=n; ++i)printf("%d ",a[i]);
printf("%d %d",a[n],a[n]);
}
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
int T=1;
while(T--)Main();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 31ms
memory: 10880kb
input:
249665 195633 37425 205189 128330 159707 98406 111454 30346 158516 121742 107964 50039 201395 16843 182333 60177 195166 188257 172666 71779 157060 237654 123572 145065 57507 152240 187931 5706 191077 214174 70950 71272 172767 61529 85258 74139 44633 181186 223348 222711 19237 239887 20487 84130 1392...
output:
249665 2 237028 23936 9385 490 32380 243201 235473 27109 242136 53673 66615 222558 159199 202085 57414 127623 172631 137856 223806 39291 235672 132858 207400 94628 116353 160440 134540 108305 187549 12027 161977 249618 48713 192048 65744 199643 31 88616 103156 108853 89162 3667 235172 107036 214816 ...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 31ms
memory: 9252kb
input:
289892 233602 170432 186700 23520 1359 74354 61778 97676 141808 279091 86618 107162 187289 270874 5771 92359 256248 59758 201034 111974 157736 29506 210946 178606 275526 119662 142498 119239 245490 9443 240901 72345 207797 759 91770 131534 189757 72201 5921 152878 237072 146758 101282 50083 61126 26...
output:
289892 245154 252439 180155 136038 216848 14384 89179 78257 139094 35645 205271 59642 204766 73674 288786 184002 145706 178573 273208 185861 78560 188165 204175 59962 32781 221338 27087 277457 28887 199357 121486 216891 161903 11748 63036 125146 62420 188502 203403 201513 260435 118781 7551 211596 2...
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 34ms
memory: 14612kb
input:
292190 145417 283887 12115 4326 45188 164129 14638 269369 233283 201793 241021 17606 90840 34917 16328 180328 261955 172583 181417 7942 223673 262641 28684 237776 243658 74833 205577 122527 28528 249819 73252 270152 117871 31565 204148 216504 192924 29203 143059 154759 104752 69112 166848 232567 962...
output:
292190 2 15152 16555 75825 115043 31920 80548 124598 135080 123584 219029 105937 86923 199936 102074 257392 24518 272021 213195 107373 272825 190373 190015 260218 107904 18489 280890 124425 201779 222377 290547 138013 187578 130343 56731 58377 81556 219541 133541 230217 279654 69404 197388 85941 157...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 23ms
memory: 15876kb
input:
289638 179249 177210 122624 75928 106218 13899 249362 245081 212282 3125 52160 49231 77788 143892 158982 277667 242837 199352 19097 201259 164534 261237 201825 180668 58106 141543 286211 251784 6410 112507 51157 93955 107491 250456 58875 36203 234469 45239 283807 106103 197348 238937 162203 287869 1...
output:
289638 1 50628 199137 141518 236065 213650 103213 185157 250799 82691 207623 105033 42659 101062 235477 156153 263961 86528 65920 110017 202321 225592 289192 217953 102766 106061 42009 29372 245708 85331 260763 78877 235321 256189 263774 11602 258689 180759 21732 1558 124497 233559 168051 207576 888...
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 24ms
memory: 13104kb
input:
261175 113751 113751 247389 247389 106728 106728 249714 249714 128388 128388 216271 216271 163974 163974 245217 245217 246248 246248 51361 51361 176423 176423 19217 19217 197524 197524 251874 251874 112335 112335 160213 160213 60037 60037 250967 250967 187608 187608 214950 214950 208541 208541 25669...
output:
261175 2 2 246047 113751 148384 247389 97811 106728 136230 249714 116414 128388 138910 216271 198031 163974 122394 245217 242134 246248 193048 51361 188837 176423 208466 19217 111613 197524 258543 251874 19955 112335 64305 160213 55995 60037 8181 250967 40867 187608 127255 214950 210262 208541 35879...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 28ms
memory: 8976kb
input:
235687 63799 71109 20584 139647 35537 3706 218536 48564 213438 186010 156300 113267 147774 194058 51317 150706 90938 10941 6713 175756 29369 170762 71917 56104 19923 152417 157391 24269 651 205117 57134 130459 204707 14596 183539 32848 219225 58014 162840 153464 135755 16381 91308 77955 176504 66784...
output:
235687 200863 62026 78729 226314 45594 60488 68600 49122 201524 124590 154884 134083 115096 209138 222838 23621 74542 84005 169237 232358 134430 138139 151235 220639 188941 178181 40309 234897 120815 67850 140784 15923 226171 80121 102846 132374 140608 171445 181495 106444 156644 196987 101135 13234...
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 32ms
memory: 9104kb
input:
286065 210717 98065 272406 215134 231139 267285 38811 254951 247150 55368 273010 247371 85937 256408 11755 96321 53159 66358 234133 68621 160218 285535 185357 247070 261590 43071 54158 13202 281537 21836 3621 234524 109158 188905 62618 144070 211133 129125 262129 85892 198535 174556 2297 62475 19242...
output:
286065 21 136773 123121 151077 281847 275407 214688 163837 40888 143867 31999 222180 247723 248997 256683 185567 229482 95095 110509 36342 136170 73172 279249 118767 171292 116304 269843 112085 49607 162684 47014 31592 46763 196936 212208 165534 103667 73367 47083 50557 85851 163898 228327 237070 37...
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 29ms
memory: 14336kb
input:
296716 132049 132049 256044 256044 110447 110447 263700 263700 36769 36769 171894 171894 60205 60205 227616 227616 286799 286799 281611 281611 124684 124684 284840 284840 213378 213378 140028 140028 7425 7425 154415 154415 71482 71482 156517 156517 295706 295706 142794 142794 10192 10192 132364 1323...
output:
296716 1 1 96375 132049 236349 256044 49021 110447 132604 263700 49936 36769 154185 171894 253062 60205 208241 227616 97608 286799 260321 281611 154660 124684 194339 284840 128038 213378 10290 140028 61333 7425 46511 154415 106854 71482 121273 156517 42050 295706 1543 142794 108622 10192 166907 1323...
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 1ms
memory: 5724kb
input:
1 1
output:
-1
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 1ms
memory: 7944kb
input:
2 1 1
output:
2 2 2
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 1ms
memory: 7908kb
input:
4 1 1 4 2
output:
4 3 3 2 1
result:
ok Correct.
Test #12:
score: 0
Accepted
time: 1ms
memory: 7940kb
input:
5 2 4 3 4 3
output:
5 1 5 5 1 2
result:
ok Correct.
Test #13:
score: 0
Accepted
time: 1ms
memory: 7924kb
input:
170 170 120 157 41 148 30 14 132 155 139 91 72 110 74 112 52 68 69 106 62 141 123 70 53 129 96 134 167 87 48 28 12 37 96 118 127 119 110 128 5 51 38 60 98 23 112 137 11 73 74 47 35 105 101 67 129 10 28 46 10 20 138 36 97 44 63 162 109 168 5 80 66 100 168 124 25 121 98 103 53 22 73 21 84 44 164 12 12...
output:
170 3 45 62 120 9 75 158 36 77 140 83 61 7 135 51 55 87 67 84 3 153 116 107 50 4 24 159 65 143 40 118 47 27 62 142 37 77 147 80 117 149 75 140 65 117 36 20 99 23 148 27 9 91 164 48 81 82 116 95 96 132 13 20 38 159 99 26 56 15 47 130 154 153 10 76 62 3 46 84 1 24 110 64 168 74 73 99 121 25 52 108 1 6...
result:
ok Correct.
Test #14:
score: 0
Accepted
time: 38ms
memory: 14528kb
input:
298282 111238 21426 241947 111803 215806 257154 180196 187662 265628 113962 69090 19116 218515 256928 214215 246498 208920 166101 33496 99919 228275 241615 680 47148 193116 62529 290930 107840 27286 163363 140988 112469 35229 87471 231114 282993 90834 143707 256766 641 40265 127700 233599 188382 258...
output:
298282 1 287447 75474 264538 242304 170104 18252 38701 210600 199017 104509 167833 128632 215839 32579 145995 87337 8449 113003 235061 158576 117877 74545 29798 85118 172282 51194 276885 247755 17449 260242 191776 18101 210349 36352 74333 27311 138969 243149 206934 178955 28465 115733 35511 184708 1...
result:
ok Correct.
Test #15:
score: 0
Accepted
time: 2ms
memory: 8024kb
input:
7028 890 4919 5516 4507 881 1936 1250 6879 4020 5347 3632 2088 5719 6828 551 5743 3912 6283 4373 3916 3021 5444 433 604 2506 6891 4206 287 3619 3247 1250 3358 1476 917 1539 2040 5753 2814 1672 5945 6116 1111 1466 6149 4596 2993 3646 3255 4591 1004 4842 2980 1872 4229 5947 6638 5634 3936 4390 6775 79...
output:
7028 3 1189 2601 544 5349 6329 1142 1089 2053 6562 4304 1032 919 6912 4708 761 371 937 5097 3598 3837 543 1034 3616 3635 6056 6765 1955 5357 2103 3 6499 5466 472 6478 5350 1999 869 5192 1629 6053 5189 6725 6223 1758 2357 1360 4065 4035 495 6319 745 451 5316 6919 4787 6450 3296 6561 4675 5186 1895 69...
result:
ok Correct.
Test #16:
score: 0
Accepted
time: 4ms
memory: 8084kb
input:
32718 16672 3857 28075 31442 14228 19512 993 27269 22217 2896 23349 9568 19344 3385 7921 12538 17485 22980 27110 24464 12290 15835 22520 3365 13285 31694 5529 27028 21009 19947 9552 5335 19363 17106 17913 7719 27902 25714 23157 7832 29338 13282 28188 10767 9027 11009 12352 20744 3915 8839 5517 9251 ...
output:
32718 2 28501 31764 27539 9696 11854 13600 702 32358 26266 29545 9451 21759 15187 7976 28278 21480 4586 24657 8311 18735 6189 8487 27334 20212 26938 32043 19065 22639 26682 12612 19465 10519 12595 28915 217 8044 12955 24661 18230 15930 1991 13823 6563 6577 761 9873 25112 7171 881 23222 12441 28035 2...
result:
ok Correct.
Test #17:
score: -100
Wrong Answer
time: 19ms
memory: 7956kb
input:
249939 116706 120073 87891 238536 248923 178942 236407 175545 209802 92808 226143 235269 231651 150564 19412 193312 9344 201164 177304 66666 141887 219987 202707 120853 204395 46154 215762 14059 119025 174198 230364 145992 235982 84009 202274 123063 134691 54501 126175 1720 182402 196639 82163 23284...
output:
249941 116706 120073 87891 238536 248923 178942 236407 175545 209802 92808 226143 235269 231651 150564 19412 193312 9344 201164 177304 66666 141887 219987 202707 120853 204395 46154 215762 14059 119025 174198 230364 145992 235982 84009 202274 123063 134691 54501 126175 1720 182402 196639 82163 23284...
result:
FAIL You lose