QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#553611 | #9239. Hieroglyphs | lgvc | 0 | 29ms | 43972kb | C++23 | 2.3kb | 2024-09-08 16:34:19 | 2024-09-08 16:34:19 |
Judging History
answer
#include "hieroglyphs.h"
#include <bits/stdc++.h>
std::vector<int> A,B;
int vi2[200009],vi1[200009],dp[3009][3009],la[200009],l1[200009],
l2[200009],N,M,vq[200009];
bool vl1(int l,int r,int x) {
memset(vq,0,sizeof(vq));
for(int i=x+1;i<N;i++) {
vq[A[i]]|=1;
}
for(int i=r+1;i<M;i++) {
vq[B[i]]|=2;
}
for(int i=l+1;i<r;i++) {
if(vq[B[i]]==1) {
return 0;
}
}
return 1;
}
bool vl2(int l,int r,int x) {
memset(vq,0,sizeof(vq));
for(int i=x+1;i<M;i++) {
vq[B[i]]|=1;
}
for(int i=r+1;i<N;i++) {
vq[A[i]]|=2;
}
for(int i=l+1;i<r;i++) {
if(vq[A[i]]==1) {
return 0;
}
}
return 1;
}
std::vector<int> ucs(std::vector<int> AA, std::vector<int> BB) {
A=AA;B=BB;
N=A.size(),M=B.size();
memset(vi2,0,sizeof(vi2));
memset(vi1,0,sizeof(vi1));
std::vector<int> wj;wj.push_back(-1);
for(int i=M-1;i>=0;i--) {
vi2[B[i]]++;
}
for(int i=N-1;i>=0;i--) {
vi1[A[i]]++;
}
for(int i=0;i<=200000;i++) {
if(vi1[i]==vi2[i]) vi1[i]=vi2[i]=1;
else if(vi1[i]<=vi2[i]) vi2[i]=0;
else vi1[i]=0;
}
dp[0][0]=1;
for(int i=0;i<=N;i++) {
for(int j=0;j<=M;j++) {
if(i&&j&&A[i-1]==B[j-1]) {
dp[i][j]|=dp[i-1][j-1];
}
if(i&&vi1[A[i-1]]==0) dp[i][j]|=dp[i-1][j];
if(j&&vi2[B[j-1]]==0) dp[i][j]|=dp[i][j-1];
}
}
if(!dp[N][M]) {
return wj;
}
std::vector<int> tp,tp2;
int x=N,y=M;
while(x||y) {
if(x&&vi1[A[x-1]]==0&&dp[x-1][y]) {
x--;
} else if(y&&vi2[B[y-1]]==0&&dp[x][y-1]){
y--;
} else {
tp.push_back(x-1);
tp2.push_back(y-1);
x--;y--;
}
}
std::reverse(tp.begin(),tp.end());
std::reverse(tp2.begin(),tp2.end());
memset(vi1,0,sizeof(vi1));
memset(vi2,0,sizeof(vi2));
for(int i=0;i<tp.size();i++) vi1[tp[i]]=1;
for(int i=0;i<tp.size();i++) vi2[tp2[i]]=1;
memset(la,-1,sizeof(la));
for(int i=0;i<N;i++) {
l1[i]=la[A[i]];
la[A[i]]=i;
}
memset(la,-1,sizeof(la));
for(int i=0;i<M;i++) {
l2[i]=la[B[i]];
la[B[i]]=i;
}
for(int i=0;i<tp.size();i++) {
int x=l2[tp2[i]];
if(x==-1||vi2[x]) continue;
if(!vl1(x,tp2[i],tp[i])) return wj;
}
for(int i=0;i<tp2.size();i++) {
int x=l1[tp[i]];
if(x==-1||vi1[x]) continue;
if(!vl2(x,tp[i],tp2[i])) return wj;
}
for(int i=0;i<tp.size();i++) tp[i]=A[tp[i]];
return tp;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 3
Accepted
time: 0ms
memory: 10808kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 10 10 7 1 9 2 3 5 0 6 8 4 7 1 9 2 3 5 0 6 8 4
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 10 7 1 9 2 3 5 0 6 8 4
result:
ok
Test #2:
score: 3
Accepted
time: 0ms
memory: 9444kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 10 10 7 9 4 5 6 8 2 1 3 0 7 9 4 5 8 6 2 1 3 0
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 1 -1
result:
ok
Test #3:
score: 3
Accepted
time: 5ms
memory: 21652kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 1000 1000 227 14 144 355 329 614 282 987 90 67 421 904 584 672 129 286 187 498 450 29 342 688 521 133 585 769 794 138 731 946 28 996 402 935 96 855 2 186 361 1 451 914 318 720 296 389 356 364 400 971 387 979 520 885 604 62 814 474 479 952 394 640 959 246 509 171 486 ...
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 1000 227 14 144 355 329 614 282 987 90 67 421 904 584 672 129 286 187 498 450 29 342 688 521 133 585 769 794 138 731 946 28 996 402 935 96 855 2 186 361 1 451 914 318 720 296 389 356 364 400 971 387 979 520 885 604 62 814 474 479 952 394 640 959 246 509 171 486 35...
result:
ok
Test #4:
score: 3
Accepted
time: 0ms
memory: 19732kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 997 997 615 691 867 398 544 236 744 802 466 701 700 106 636 993 668 105 409 810 957 249 619 293 729 339 189 537 70 237 487 360 276 693 181 954 85 310 669 52 86 12 209 787 294 188 64 561 828 44 564 480 895 283 289 924 192 783 890 948 674 279 114 229 822 771 458 179 65...
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 1 -1
result:
ok
Test #5:
score: 0
Runtime Error
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 100000 100000 19751 36170 33104 26686 54203 5214 37609 58763 10536 82655 80942 70794 54794 16739 55137 38172 11159 41408 34850 54300 58781 6684 19791 28867 83340 19360 7277 54060 59942 87198 45397 49198 66950 26865 7468 7059 58566 43804 99565 76536 48614 34101 26106 ...
output:
result:
Subtask #2:
score: 0
Time Limit Exceeded
Test #8:
score: 0
Time Limit Exceeded
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 89984 90016 167910 187180 47437 150113 199404 61979 49501 155514 167910 175137 104441 149717 155514 13573 170025 181983 117868 13573 149717 166954 145922 29787 93788 58581 158693 51768 120499 17700 17700 4746 119328 33450 138501 137246 33450 135751 84363 168724 15701...
output:
result:
Subtask #3:
score: 0
Time Limit Exceeded
Test #71:
score: 0
Time Limit Exceeded
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 100000 100000 0 1 0 0 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 0 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1 1 0 1 0 0 0 1 0 1 0 1 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 1 1 1 0 1 0...
output:
result:
Subtask #4:
score: 0
Runtime Error
Test #97:
score: 0
Runtime Error
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 20000 30000 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110...
output:
result:
Subtask #5:
score: 0
Wrong Answer
Test #132:
score: 14
Accepted
time: 20ms
memory: 42904kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 2800 2999 47 51 42 122 38 125 170 11 119 48 289 297 27 150 207 271 11 15 67 287 149 220 76 274 128 151 60 117 39 123 254 75 170 198 72 179 274 203 13 88 139 153 46 288 13 282 16 219 284 91 274 63 190 157 72 286 238 1 219 82 82 31 285 128 198 172 161 271 36 111 160 26...
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 2800 47 51 42 122 38 125 170 11 119 48 289 297 27 150 207 271 11 15 67 287 149 220 76 274 128 151 60 117 39 123 254 75 170 198 72 179 274 203 13 88 139 153 46 288 13 282 16 219 284 91 274 63 190 157 72 286 238 1 219 82 82 31 285 128 198 172 161 271 36 111 160 268 ...
result:
ok
Test #133:
score: 14
Accepted
time: 19ms
memory: 43972kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 2999 2999 161 462 13 332 346 475 194 20 36 323 39 256 432 278 259 480 97 464 354 69 375 262 103 321 65 264 31 471 439 314 169 353 165 346 444 148 337 326 359 397 396 489 391 74 168 209 496 183 481 9 485 46 174 410 158 363 179 56 118 294 350 290 154 74 95 202 490 62 3...
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 2700 161 462 13 332 346 475 194 20 36 323 39 256 432 278 259 480 97 464 354 69 375 262 103 321 65 264 31 471 439 314 169 353 165 346 444 148 337 326 359 397 396 489 391 74 168 209 496 183 481 9 485 46 174 410 158 363 179 56 118 294 350 290 154 74 95 202 490 62 397...
result:
ok
Test #134:
score: 14
Accepted
time: 23ms
memory: 43968kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 2999 2999 843 300 400 262 3 359 867 592 609 694 416 694 749 14 997 584 22 452 74 61 908 659 456 301 694 412 793 433 213 885 304 161 506 502 462 654 694 875 983 177 743 313 380 316 473 748 254 659 997 132 100 335 437 825 192 182 213 575 740 442 622 833 694 914 332 341...
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 2500 843 300 400 262 3 359 867 592 609 416 749 14 997 584 22 452 74 61 908 659 456 301 412 793 433 213 885 304 161 506 502 462 654 875 983 177 743 313 380 316 473 748 254 659 997 132 100 335 437 825 192 182 213 575 740 442 622 833 914 332 341 153 931 749 819 985 8...
result:
ok
Test #135:
score: 14
Accepted
time: 29ms
memory: 43428kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 2999 2999 863 1603 1420 106 1789 1690 1900 525 13 1749 747 263 87 0 1117 24 1318 1166 1233 749 337 1130 1780 1156 1918 1245 526 204 507 1440 728 1038 685 83 723 1929 1011 386 1132 1358 1022 1611 861 388 1168 1302 197 1958 1110 1573 1129 1808 357 1656 323 1670 799 983...
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 2300 863 1603 1420 106 1789 1690 13 1749 747 0 1117 24 1318 1166 749 337 1130 1780 1156 1918 1245 526 204 507 728 1038 685 83 723 1929 1011 386 1132 1358 1022 1611 388 1168 1302 197 1110 1573 1129 1808 357 1656 323 1670 641 1673 633 188 1557 1747 322 807 544 1118 ...
result:
ok
Test #136:
score: 14
Accepted
time: 28ms
memory: 42340kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 2801 2999 242 250 180 109 252 104 276 77 206 10 83 106 187 18 185 122 29 94 87 53 142 172 135 197 70 55 243 242 289 268 125 66 293 276 133 121 299 113 279 71 195 221 23 139 85 246 287 128 198 184 145 140 268 129 210 148 7 222 186 14 282 184 121 42 146 222 239 184 217...
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 1 -1
result:
ok
Test #137:
score: 0
Wrong Answer
time: 20ms
memory: 42220kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 2735 2999 253 21 90 69 49 28 433 494 182 261 143 211 114 170 493 307 26 29 69 427 285 452 183 134 483 226 249 242 232 282 52 213 341 447 50 484 322 210 35 376 479 465 61 446 413 325 351 125 16 43 379 376 322 315 235 237 163 321 349 434 293 359 353 420 91 75 351 279 4...
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 2700 253 21 90 69 49 28 433 494 182 261 143 211 114 170 493 307 26 29 69 427 285 452 183 134 483 226 249 242 232 282 52 213 341 447 50 484 322 210 35 376 479 465 61 446 413 325 351 125 16 43 379 376 322 315 235 237 163 321 349 434 293 353 420 91 75 351 279 497 177...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '1', found: '2700'
Subtask #6:
score: 0
Skipped
Dependency #1:
0%