QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#293828#4826. Find the Partsucup-team266#0 3ms4100kbC++203.1kb2023-12-29 20:20:112023-12-29 20:20:11

Judging History

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

  • [2023-12-29 20:20:11]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:4100kb
  • [2023-12-29 20:20:11]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
string s="0123456789ABCDEF";
string base16(int val)
{
	string ans="..";
	ans[0]=s[val/16];
	ans[1]=s[val%16];
	return ans;
}
int base10(char ch)
{
	if(isdigit(ch)) return ch^48;
	return ch-'A'+10;
}
int base10(string s)
{
	return base10(s[0])*16+base10(s[1]);
}
int grid[2020][2020];
int trans[10005*21*21][2];
int ind[10005*21*21];
int h[10005],w[10005],ax[10005],ay[10005],tot=1;
int main()
{
//	freopen("001.phase2.full.input","r",stdin);
//	freopen("C.ans","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string mode;
	cin>>mode;
	if(mode=="message")
	{
		int n,m;
		cin>>n>>m;
		vector<int> vec;
		vector<int> ans;
		ans.pb(n/256);
		ans.pb(n%256);
		ans.pb(m/256);
		ans.pb(m%256);
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
			{
				string s;
				cin>>s;
				if(isdigit(s[1]))
					vec.pb(s[1]&1);
				else
					vec.pb((s[1]&1)^1);
			}
		while(sz(vec)%8) vec.pb(0);
		for(int i=0;i<sz(vec);i+=8)
		{
			int val=0;
			for(int j=0;j<8;j++)
				val|=(vec[i+j]<<j);
			ans.pb(val);
		}
		cout<<sz(ans)<<endl;
		for(auto val:ans)
			cout<<base16(val)<<" ";
		return 0;
	}
	if(mode=="parts")
	{
		vector<int> mem;
		int tot;
		cin>>tot;
		for(int i=0;i<tot;i++)
		{
			string byte;
			cin>>byte;
			mem.pb(base10(byte));
		}
		int n=mem[0]*256+mem[1];
		int m=mem[2]*256+mem[3];
		cerr<<n<<" "<<m<<endl;
		vector<int> bits;
		for(int i=4;i<sz(mem);i++)
			for(int j=0;j<8;j++)
				bits.pb(mem[i]>>j&1);
		while(sz(bits)>n*m) bits.pop_back();
		int p=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				grid[i][j]=bits[p++];
		int q;
		cin>>q;
		for(int i=1;i<=q;i++)
		{
			cin>>h[i]>>w[i];
			vector<int> vec;
			for(int a=1;a<=h[i];a++)
				for(int b=1;b<=w[i];b++)
				{
					string s;
					cin>>s;
					if(isdigit(s[1]))
						vec.pb(s[1]&1);
					else
						vec.pb((s[1]&1)^1);
				}
			int cur=1;
			for(auto b:vec)
			{
				if(!trans[cur][b])
					trans[cur][b]=++tot;
				cur=trans[cur][b];
			}
			ind[cur]=i;
		}
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				for(int qw=10;qw<=20&&j+qw-1<=m;qw++)
				{
					int nd=1;
					for(int qh=1;nd;qh++)
					{
						for(int tw=0;tw<qw&&nd;tw++)
							nd=trans[nd][grid[i+qh-1][j+tw]];
						if(ind[nd]&&h[ind[nd]]==qh&&w[ind[nd]]==qw)
						{
							ax[ind[nd]]=i;
							ay[ind[nd]]=j;
						}
					}
				}
		for(int i=1;i<=q;i++)
			cout<<ax[i]<<" "<<ay[i]<<endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3564kb

input:

message
20 24
33 39 73 4A 5A AA E0 86 96 4B 0B 83 A0 FA 82 9B B0 6E DC 03 1C B9 5B 81
86 3E 23 7B C9 38 77 82 7D 62 EA CE A8 DE 85 6C 36 B3 10 EE 85 6A D5 92
14 BD 58 74 20 7B 36 E1 89 B8 6F 4A F4 8F 17 2E 2F 0F 79 DD AA 9F 6F AD
85 21 B6 2F 58 37 87 7B 3F EE D9 7D 9A E6 AA 12 E0 B6 BB 3D 72 BD 34 A...

output:

64
00 14 00 18 07 8E E8 5C 41 52 A2 65 EF EB 0D AC B5 76 5B AF 69 57 9F 4B 30 0E A9 88 7F 63 EB 35 73 F5 3A 11 0F 5B 07 A8 BE C3 19 EA C7 0A F2 91 40 AD 4A F6 F2 BC 13 2A F1 68 ED BE CA B5 AC D0 

input:

parts
64
00 14 00 18 07 8E E8 5C 41 52 A2 65 EF EB 0D AC B5 76 5B AF 69 57 9F 4B 30 0E A9 88 7F 63 EB 35 73 F5 3A 11 0F 5B 07 A8 BE C3 19 EA C7 0A F2 91 40 AD 4A F6 F2 BC 13 2A F1 68 ED BE CA B5 AC D0
2
10 10
39 73 4A 5A AA E0 86 96 4B 0B
3E 23 7B C9 38 77 82 7D 62 EA
BD 58 74 20 7B 36 E1 89 B8 6F
2...

output:

1 2
6 5

result:

ok correct answer

Test #2:

score: 100
Accepted
time: 1ms
memory: 3568kb

input:

message
20 20
85 C4 91 58 77 23 A9 E5 44 8E 28 DC A2 51 13 AE 4E 3C 21 62
37 5A 41 45 8F CA C3 89 01 68 11 72 D8 75 72 ED EE 64 FA B0
05 45 6E F2 FD CE 9A AC 31 CA 88 83 34 D6 23 1F 8C 6D 9E 8C
42 40 7E 18 4C D1 D3 F2 02 20 51 20 14 0F 3D 27 0E 03 73 D7
C0 1F C3 1D D3 55 D9 AF 6E 76 77 28 24 1A 97 E...

output:

54
00 14 00 14 F5 60 D4 5D 0A 13 C9 02 46 EE FE 44 BA F8 54 09 98 96 40 78 8B 2B D2 15 8E C3 A4 F1 1B C8 4A 5C 7E 90 33 40 EB 71 90 3C 70 D9 3B 46 E9 12 2B D9 DC F2 

input:

parts
54
00 14 00 14 F5 60 D4 5D 0A 13 C9 02 46 EE FE 44 BA F8 54 09 98 96 40 78 8B 2B D2 15 8E C3 A4 F1 1B C8 4A 5C 7E 90 33 40 EB 71 90 3C 70 D9 3B 46 E9 12 2B D9 DC F2
1
10 10
D0 0A D3 6D B9 31 31 76 54 15
CE 14 02 1A A2 8C 77 EB 8E 02
06 44 E4 F4 22 DB 66 F8 7E 38
C6 6A B7 5F E1 A0 0D F0 F5 8A
A...

output:

6 6

result:

ok correct answer

Test #3:

score: 100
Accepted
time: 1ms
memory: 3684kb

input:

message
20 20
12 4F 58 0D 8B AB 72 D1 55 0F FC 74 28 E3 B0 02 9E FA 18 C0
82 72 32 EB 29 EF 9D 70 E6 2D AC 15 37 31 40 A4 36 B6 58 2C
4E C2 4D AC C5 0F D1 A8 B2 2D 43 ED 00 63 7C 3B 3E C5 94 49
92 7D 2C 69 2B 6A 15 95 7C FD 67 E4 AC EE 01 F8 78 5F 46 57
54 7D 03 92 36 85 D0 C0 B1 14 22 70 9D 06 4E C...

output:

54
00 14 00 14 BA 23 80 A7 03 74 AE AA 6D A4 26 11 17 51 54 25 AE A4 1B 21 7C 01 6A DA D6 00 3D 8C 30 B4 92 2F E9 C9 B9 28 D3 B4 A5 EA 91 E3 45 C0 72 71 B1 17 33 53 

input:

parts
54
00 14 00 14 BA 23 80 A7 03 74 AE AA 6D A4 26 11 17 51 54 25 AE A4 1B 21 7C 01 6A DA D6 00 3D 8C 30 B4 92 2F E9 C9 B9 28 D3 B4 A5 EA 91 E3 45 C0 72 71 B1 17 33 53
9
10 10
12 4F 58 0D 8B AB 72 D1 55 0F
82 72 32 EB 29 EF 9D 70 E6 2D
4E C2 4D AC C5 0F D1 A8 B2 2D
92 7D 2C 69 2B 6A 15 95 7C FD
5...

output:

1 1
11 11
1 11
11 1
1 1
11 1
1 1
1 11
1 1

result:

ok correct answer

Test #4:

score: 0
Wrong Answer
time: 3ms
memory: 4100kb

input:

message
43 37
EA A3 A3 FC CB 58 F5 40 43 D7 44 FA 09 74 25 84 25 7B 87 E4 98 7A 7F 9D 8D 73 46 AA F4 BF 73 DB EF 46 7D DA B5
7B C6 A2 A3 EF 7C 14 EE 10 1C DE 08 ED E8 2C BD F6 F7 2B 7D 82 B6 0D 0C 06 17 56 84 DD 96 29 77 C0 EE 70 EB 9F
16 A6 27 3A 32 52 AE 0E 31 A7 D2 1D B9 EC D2 20 3D 7D 84 12 4B 5...

output:

203
00 2B 00 25 56 53 C7 E3 35 03 D2 49 1A 13 6C CC 2B 10 E4 A4 7A 05 1F F6 53 29 83 C5 3B 85 CC 42 0A F3 1B C5 D1 57 D5 76 B5 26 D4 05 57 DE 27 DF 0D 5E D5 32 5B 00 F7 1D 93 B2 AF F3 45 B6 EC A7 8C C5 BC 0C CE ED F3 80 01 66 99 B4 AD 71 4B C8 27 85 69 7F 6C 54 6E 0F 9C 00 14 AC 26 7F 4D C0 A4 A6 79...

input:

parts
203
00 2B 00 25 56 53 C7 E3 35 03 D2 49 1A 13 6C CC 2B 10 E4 A4 7A 05 1F F6 53 29 83 C5 3B 85 CC 42 0A F3 1B C5 D1 57 D5 76 B5 26 D4 05 57 DE 27 DF 0D 5E D5 32 5B 00 F7 1D 93 B2 AF F3 45 B6 EC A7 8C C5 BC 0C CE ED F3 80 01 66 99 B4 AD 71 4B C8 27 85 69 7F 6C 54 6E 0F 9C 00 14 AC 26 7F 4D C0 A4...

output:

10 9
25 16
17 16
9 16
26 9
24 17
7 19
3 16
17 2
15 23
13 26
24 20
13 3
21 8
16 17
7 8
6 21
3 6
6 15
27 6
0 0
16 18
12 11
32 14
6 12
1 16
19 24
31 12
5 2
18 25
7 9
1 6
10 17
16 8
3 16
3 7
13 21
18 1
14 10
8 7
21 1
26 5
4 13
22 16
6 15
29 12
15 12
31 10
5 16
4 15
26 3
3 11
17 27
9 3
12 16
6 10
12 8
10...

result:

wrong answer wrong answer on query 21: read (0, 0) but expected (9, 12)