QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559471#9239. HieroglyphsCrysfly0 38ms22760kbC++172.4kb2024-09-11 22:16:402024-09-11 22:16:40

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 22:16:40]
  • 评测
  • 测评结果:0
  • 用时:38ms
  • 内存:22760kb
  • [2024-09-11 22:16:40]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
//#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

vi NO={-1};
int n,m,a[maxn],b[maxn];

int f[3005][3005];
vi brute(){
	For(i,1,n){
		For(j,1,m)
			f[i][j]=max({f[i-1][j],f[i][j-1],f[i-1][j-1]+(a[i]==b[j])});
	}
	int u=n,v=m;
	vi t;
	while(u>1 || v>1){
		if(a[u]==b[v]) t.pb(a[u]),--u,--v;
		else if(v && f[u][v]==f[u][v-1]) --v;
		else --u;
	}
	reverse(ALL(t));
	return t;
}

vi va[maxn],vb[maxn];
int opa[maxn],opb[maxn];

pii gpre(vi &o,int x){
	auto it=lower_bound(ALL(o),x);
	if(it==o.begin()) return mkp(-1,SZ(o));
	--it;
	return mkp(*it,o.end()-it-1);
}

pii geta(int x,int c){
	return gpre(va[c],x);
}
pii getb(int x,int c){
	return gpre(vb[c],x);
}

int cnt[maxn];

vi get(){
	For(i,1,n) va[a[i]].pb(i);
	For(i,1,m) vb[b[i]].pb(i);
	For(i,0,200000)
		if(va[i].size()<=vb[i].size()) {
			for(int x:va[i]) opa[x]=1,++cnt[i];
		}else{
			for(int x:vb[i]) opb[x]=1,++cnt[i];
		}
	vi res;
	int pa=1,pb=1;
	
	auto A=[&](){
		--cnt[a[pa]],res.pb(a[pa]),++pa;
	};
	auto B=[&](){
		--cnt[b[pb]],res.pb(b[pb]),++pb;
	};
	
	while(pa<=n || pb<=m){
		while(pa<=n && !opa[pa])++pa;
		while(pb<=m && !opb[pb])++pb;
		bool oka=(pa<=n),okb=(pb<=m);
		if(!oka || !okb){
			if(oka) A();
			else B();
			continue;
		}
		auto [qb,cb]=geta(pa,b[pb]);
		auto [qa,ca]=getb(pb,a[pa]);
		
		if(qa>pb) oka=0;
		if(qb>pa) okb=0;
		if(cb<cnt[b[pb]]) oka=0;
		if(ca<cnt[a[pa]]) okb=0;
		
		if(!oka && !okb) return NO;
		if(oka && okb) return NO;
		if(oka) A();
		else B();
	}
	return res;
}

vi ucs(vi A,vi B)
{
	n=A.size(),m=B.size();
	For(i,1,n)a[i]=A[i-1];
	For(i,1,m)b[i]=B[i-1];
	vi o=get();
	return o;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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

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
10
7 9 4 5 6 8 2 1 3 0

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 38ms
memory: 20884kb

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

Test #71:

score: 0
Wrong Answer
time: 19ms
memory: 21164kb

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:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
1
-1

result:

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

Subtask #4:

score: 0
Wrong Answer

Test #97:

score: 16
Accepted
time: 10ms
memory: 17280kb

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: 16
Accepted
time: 24ms
memory: 21036kb

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:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
88886
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 22478 ...

result:

ok 

Test #99:

score: 16
Accepted
time: 23ms
memory: 22156kb

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
100000 100000
166304 166304 166304 166304 166304 166304 166304 166304 102708 11497 11497 11497 11497 11497 11497 11497 11497 17510 17510 17510 17510 17510 17510 17510 17510 17510 17510 17510 17510 17510 17510 17510 125776 125776 125776 125776 125776 125776 125776 125...

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
85709
166304 166304 166304 166304 166304 166304 166304 102708 11497 11497 11497 11497 11497 17510 17510 17510 17510 17510 17510 17510 17510 17510 17510 17510 17510 125776 125776 125776 125776 125776 125776 125776 125776 125776 125776 125776 125776 125776 125776 12...

result:

ok 

Test #100:

score: 16
Accepted
time: 24ms
memory: 18652kb

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
100000 100000
117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 1...

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
95801
117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117 117117...

result:

ok 

Test #101:

score: 16
Accepted
time: 16ms
memory: 21336kb

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
100000 100000
127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 1...

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
98803
127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501 127501...

result:

ok 

Test #102:

score: 16
Accepted
time: 14ms
memory: 21520kb

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
100000 100000
116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 1...

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
99078
116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473 116473...

result:

ok 

Test #103:

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

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
90001 89999
171539 66534 9757 176662 84211 83487 129394 86197 172362 142984 93418 146577 96159 191701 83516 196081 37110 105351 165140 54539 124569 187177 24718 194979 119131 15727 40820 31718 13095 147840 76889 199389 75862 118045 115442 10325 157261 11275 83362 174...

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
1
-1

result:

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

Subtask #5:

score: 0
Wrong Answer

Test #132:

score: 14
Accepted
time: 5ms
memory: 18280kb

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

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

result:

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

Subtask #6:

score: 0
Skipped

Dependency #1:

0%