QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559486#9239. Hieroglyphszhouhuanyi0 240ms26348kbC++172.6kb2024-09-11 22:23:482024-09-11 22:23:50

Judging History

This is the latest submission verdict.

  • [2024-09-11 22:23:50]
  • Judged
  • Verdict: 0
  • Time: 240ms
  • Memory: 26348kb
  • [2024-09-11 22:23:48]
  • Submitted

answer

#include "hieroglyphs.h"
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define N 200000
using namespace std;
const int inf=(int)(1e9);
vector<int>p[N+1];
vector<int>p2[N+1];
struct reads
{
	int num,data;
	bool operator < (const reads &t)const
	{
		return num<t.num;	
	}
};
reads tong[N+1],tong2[N+1];
int length,length2,leng,dque[N+1],dque2[N+1],pst,pst2,l[N+1],l2[N+1],r[N+1],r2[N+1],st[N+1],nt[N+1],nt2[N+1];
bool used[N+1],used2[N+1];
int get(int x,int d)
{
	return lower_bound(p[x].begin(),p[x].end(),d)-p[x].begin();
}
int get2(int x,int d)
{
	return lower_bound(p2[x].begin(),p2[x].end(),d)-p2[x].begin();
}
bool cmp(reads a,reads b)
{
	int d;
	if (get(a.data,nt[b.num])==get2(a.data,b.num)) d=nt[b.num];
	else d=nt2[b.num];
	return a.num<d;
}
std::vector<int> ucs(std::vector<int> A, std::vector<int> B)
{
	int ps=0,pst=-1,pst2=-1;
	bool op=0;
	vector<int>v;
	for (int i=0;i<A.size();++i) p[A[i]].push_back(i);
	for (int i=0;i<B.size();++i) p2[B[i]].push_back(i);
	for (int i=0;i<=N;++i)
	{
		if (p[i].size()<p2[i].size())
		{
			for (int j=0;j<p[i].size();++j) tong[++length]=(reads){p[i][j],i};
		}
		else
		{
			for (int j=0;j<p2[i].size();++j) tong2[++length2]=(reads){p2[i][j],i},nt[p2[i][j]]=p[i][j],nt2[p2[i][j]]=p[i][p[i].size()-p2[i].size()+j];
		}
	}
	sort(tong+1,tong+length+1),sort(tong2+1,tong2+length2+1);
	for (int i=1;i<=length2;++i)
	{
		while (ps+1<=length&&cmp(tong[ps+1],tong2[i])) st[++leng]=tong[++ps].data;
		st[++leng]=tong2[i].data;
	}
	for (int i=ps+1;i<=length;++i) st[++leng]=tong[i].data;
	for (int i=1;i<=leng;++i)
	{
		pst++,pst2++;
		while (pst<A.size()&&A[pst]!=st[i]) ++pst;
		while (pst2<B.size()&&B[pst2]!=st[i]) ++pst2;
		if (pst==A.size()||pst2==B.size()) return {-1};
		dque[i]=pst,dque2[i]=pst2,used[pst]=used2[pst2]=1,v.push_back(st[i]);
	}
	for (int i=0;i<=N;++i) l[i]=l2[i]=inf,r[i]=r2[i]=-inf;
	for (int i=0;i<A.size();++i)
		if (!used[i])
			l[A[i]]=min(l[A[i]],i),r[A[i]]=max(r[A[i]],i);
	for (int i=0;i<B.size();++i)
		if (!used2[i])
			l2[B[i]]=min(l2[B[i]],i),r2[B[i]]=max(r2[B[i]],i);
	for (int i=1;i<=leng;++i)
	{
		if (l[st[i]]<dque[i]) op=1;
		if (dque2[i]<r2[st[i]]&&op) return {-1};
	}
	op=0;
	for (int i=1;i<=leng;++i)
	{
		if (l2[st[i]]<dque2[i]) op=1;
		if (dque[i]<r[st[i]]&&op) return {-1};
	}
	for (int i=1;i<=leng;++i)
		for (int j=i+1;j<=leng;++j)
			if (r[st[i]]>dque[j]&&l2[st[j]]<dque2[i])
				return {-1};
	for (int i=1;i<=leng;++i)
		for (int j=i+1;j<=leng;++j)
			if (r2[st[i]]>dque2[j]&&l[st[j]]<dque[i])
				return {-1};
	return v;
}

詳細信息

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 3
Accepted
time: 4ms
memory: 21344kb

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: 3ms
memory: 18976kb

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: 2ms
memory: 17720kb

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: 19404kb

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
Time Limit Exceeded

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
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 28ms
memory: 26348kb

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:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
1
-1

result:

wrong answer 3rd lines differ - on the 1st token, expected: '60000', found: '1'

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
Time Limit Exceeded

Test #97:

score: 16
Accepted
time: 240ms
memory: 20680kb

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:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
20000
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 110955...

result:

ok 

Test #98:

score: 0
Time Limit Exceeded

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
99999 88888
22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 22478 224...

output:


result:


Subtask #5:

score: 0
Wrong Answer

Test #132:

score: 14
Accepted
time: 7ms
memory: 21248kb

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: 4ms
memory: 20968kb

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: 6ms
memory: 20700kb

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: 0
Wrong Answer
time: 0ms
memory: 20852kb

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
1
-1

result:

wrong answer 3rd lines differ - on the 1st token, expected: '2300', found: '1'

Subtask #6:

score: 0
Skipped

Dependency #1:

0%