QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#87309 | #5687. 速战速决 | smallTarjan# | WA | 486ms | 21300kb | C++14 | 1.5kb | 2023-03-12 14:27:04 | 2023-03-12 14:27:08 |
Judging History
answer
#include <cstdio>
#include <map>
using namespace std;
#define re int
#define maxn 300005
int n;
int a[maxn];
int vs[maxn];
int ok[maxn];
int top;
int zhan[maxn];
map<int, int> mp;
int main()
{
scanf("%d", &n);
re i;
for(i = 1;i <= n;i++) vs[i] = 2;
for(i = 1;i <= n;i++) scanf("%d", &a[i]), vs[a[i]]--;
if(n == 1){
printf("-1\n");
return 0;
}
int f = 0;
for(i = 1;i <= n;i++){
if(vs[i]) mp[i] = vs[i];
if(vs[i] == 2) f = i;
}
if(!f) {
printf("-1\n");
return 0;
}
printf("%d\n", n);
printf("%d ", f);
map<int, int>::iterator it;
zhan[++top] = f, ok[f] = 1, mp[f]--;
int x;
for(i = 1;i < n;i++){
ok[a[i]] = 1, zhan[++top] = a[i];
if(ok[a[i + 1]]){
printf("%d ", f);
while(zhan[top] != f) {
mp[zhan[top]]++, ok[zhan[top]] = 0, top--;
}
mp[zhan[top]]++, ok[zhan[top]] = 0, top--;
f = a[i + 1];
}
else {
it = mp.end();
it--;
while(it -> first == a[i + 1] || it -> first == f) it--;
x = it -> first;
//printf("?%d? ", mp[8]);
printf("%d ", x);
mp[x]--, zhan[++top] = x, ok[x] = 1;
//printf("?%d?\n", mp[8]);
if(mp[x] == 0)
mp.erase(x);
}
}
return 0;
}
/*
3
1 3 3
1
1
5
1 2 3 4 4
8
1 2 2 3 4 5 3 1
*/
详细
Test #1:
score: 100
Accepted
time: 312ms
memory: 18400kb
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 249660 249664 249663 249662 249661 249659 249657 249656 249655 249654 249654 249653 249652 249652 249651 249649 249648 249648 249647 249645 249644 249644 249643 249642 249640 249640 249639 249637 249635 249634 249633 249632 249632 249631 249631 249629 249628 249628 249627 249626 249624 249623...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 427ms
memory: 20104kb
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 289892 289891 289890 289889 289888 289887 289886 289885 289884 289883 289882 289881 289880 289879 289878 289877 289876 289875 289874 289873 289872 289871 289870 289869 289868 289867 289866 289865 289864 289863 289862 289861 289860 289859 289858 289857 289856 289855 289854 289853 289852...
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 447ms
memory: 20816kb
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 292190 292189 292189 292188 292188 292185 292185 292183 292183 292181 292181 292180 292180 292179 292179 292177 292177 292175 292175 292172 292172 292171 292171 292167 292167 292166 292166 292165 292165 292164 292164 292162 292162 292157 292157 292156 292156 292154 292154 292152 292152 292151...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 282ms
memory: 21300kb
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 289636 289635 289635 289633 289633 289632 289632 289630 289630 289627 289627 289626 289626 289624 289624 289623 289623 289620 289620 289619 289619 289618 289618 289615 289615 289614 289614 289612 289612 289611 289611 289609 289609 289604 289604 289603 289603 289600 289600 289599 289599 289598...
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 228ms
memory: 18608kb
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 261175 261175 261175 113751 261175 247389 261175 106728 261175 249714 261175 128388 261175 216271 261175 163974 261175 245217 261175 246248 261175 51361 261175 176423 261175 19217 261175 197524 261175 251874 261175 112335 261175 160213 261175 60037 261175 250967 261175 187608 261175 214950 26...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 316ms
memory: 17472kb
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 235687 235686 235685 235684 235683 235682 235681 235680 235679 235678 235677 235676 235675 235674 235673 235672 235671 235670 235669 235668 235667 235666 235665 235664 235663 235662 235661 235660 235659 235658 235657 235656 235655 235654 235653 235652 235651 235650 235649 235648 235647...
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 486ms
memory: 20036kb
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 286062 286064 286063 286060 286059 286059 286058 286056 286056 286055 286053 286052 286051 286051 286048 286047 286046 286046 286043 286042 286040 286039 286038 286037 286037 286036 286032 286032 286031 286030 286029 286027 286026 286024 286023 286020 286020 286019 286018 286017 286016 286014...
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 251ms
memory: 20504kb
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 296716 296716 296716 132049 296716 256044 296716 110447 296716 263700 296716 36769 296716 171894 296716 60205 296716 227616 296716 286799 296716 281611 296716 124684 296716 284840 296716 213378 296716 140028 296716 7425 296716 154415 296716 71482 296716 156517 296716 295706 296716 142794 2967...
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 2ms
memory: 7116kb
input:
1 1
output:
-1
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 2ms
memory: 7112kb
input:
2 1 1
output:
2 2 2
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 2ms
memory: 5068kb
input:
4 1 1 4 2
output:
4 3 3 3 4
result:
ok Correct.
Test #12:
score: 0
Accepted
time: 0ms
memory: 7120kb
input:
5 2 4 3 4 3
output:
5 5 2 1 5 5
result:
ok Correct.
Test #13:
score: 0
Accepted
time: 3ms
memory: 5204kb
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 163 167 165 164 162 160 160 159 158 158 157 156 155 154 154 153 152 152 151 151 149 148 147 144 143 142 142 163 170 165 164 163 163 162 160 160 159 158 158 157 157 156 155 155 154 154 153 152 152 151 151 149 148 148 147 144 143 167 170 167 167 165 164 163 163 162 28 170 167 167 165 164 163 162 1...
result:
ok Correct.
Test #14:
score: 0
Accepted
time: 414ms
memory: 20604kb
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 298276 298282 298281 298280 298277 298275 298275 298274 298273 298273 298272 298271 298271 298269 298269 298268 298268 298266 298265 298264 298263 298262 298261 298260 298259 298258 298257 298256 298255 298255 298254 298254 298253 298252 298251 298250 298249 298248 298246 298245 298244 298242...
result:
ok Correct.
Test #15:
score: 0
Accepted
time: 6ms
memory: 5552kb
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 7024 7028 7027 7026 7023 7023 7021 7020 7019 7018 7017 7016 7015 7014 7013 7011 7010 7010 7009 7008 7008 7007 7006 7005 7005 7004 7003 7002 7001 7001 7024 7028 7027 7026 7024 7024 7023 7023 7021 7020 7019 7018 7017 7016 7015 7014 7013 7011 7010 7010 7009 7008 7008 7007 7006 7005 7005 7004 7003 ...
result:
ok Correct.
Test #16:
score: 0
Accepted
time: 31ms
memory: 6768kb
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 32715 32717 32716 32714 32712 32711 32710 32709 32706 32706 32705 32704 32704 32703 32702 32702 32701 32700 32699 32698 32697 32697 32696 32695 32694 32693 32692 32691 32690 32689 32689 32688 32688 32687 32686 32686 32684 32683 32682 32682 32680 32678 32677 32676 32675 32675 32673 32672 32671 ...
result:
ok Correct.
Test #17:
score: -100
Wrong Answer
time: 76ms
memory: 17800kb
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:
-1
result:
wrong answer Wrong Step.