QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#321726 | #4826. Find the Parts | Skyan | 0 | 24ms | 142352kb | C++23 | 4.0kb | 2024-02-05 10:55:14 | 2024-02-05 10:55:14 |
Judging History
answer
#include <iostream>
#include <vector>
#include <map>
using namespace std;
string a[2005][2005], b[410005];
string tostring(long long int a) {
if (a == 0) return "00";
string res = "";
while (a != 0) {
res = char(a % 10 + 48) + res;
a /= 10;
}
if (res.size() == 1) res = "0" + res;
return res;
}
long long int mod = 1e14 + 31;
map<long long int, pair<int, int>> mm[21];
long long int decode(string s) {
long long int x = 0, y = 0;
if (s[0] >= '0' && s[0] <= '9') x = s[0] - '0';
else x = 10 + s[0] - 'A';
if (s[1] >= '0' && s[1] <= '9') y = s[1] - '0';
else y = 10 + s[1] - 'A';
return x * 16 + y;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
string s;
cin >> s;
if (s == "message") {
int n, m;
cin >> n >> m;
vector<string> v;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; i += 10) {
for (int j = 1; j <= m; j++) {
v.push_back(a[i][j]);
}
}
v.push_back(tostring(n / 100));
v.push_back(tostring(n % 100));
v.push_back(tostring(m / 100));
v.push_back(tostring(m % 100));
cout << v.size() << '\n';
for (auto w : v) cout << w << ' ';
}
else {
int k;
cin >> k;
for (int i = 1; i <= k; i++) cin >> b[i];
string s = b[k - 3] + b[k - 2], t = b[k - 1] + b[k];
int n = 0, m = 0;
for (int i = 0; i < s.size(); i++) n = n * 10 + s[i] - '0';
for (int i = 0; i < t.size(); i++) m = m * 10 + t[i] - '0';
k -= 4;
for (int i = 1; i <= k; i++) {
a[(i - 1) / m + 1][(i - 1) % m + 1] = b[i];
}
for (int i = 1; i <= n / 10; i++) {
for (int j = 1; j <= m; j++) {
long long int c = 0;
for (int k = j; k < min(j + 20, m + 1); k++) {
c = (c * 257 + decode(a[i][k]) + 1) % mod;
mm[k - j + 1][c] = {i * 10 - 9, j};
}
}
}
int q;
cin >> q;
for (int jj = 0; jj < q; jj++) {
int r, x;
cin >> r >> x;
for (int i = 1; i <= r; i++) {
long long int c = 0;
for (int j = 1; j <= x; j++) {
string s;
cin >> s;
c = (c * 257 + decode(s) + 1) % mod;
}
if (mm[x].count(c)) {
pair<int, int> p = mm[x][c];
int h = p.first, k = p.second;
cout << h - i + 1 << " " << k << '\n';
}
}
}
}
}
/*
parts
52
33 39 73 4A 5A AA E0 86 96 4B 0B 83 A0 FA 82 9B B0 6E DC 03 1C B9 5B 81 EC C9 BE 91 3B DF 1C DC 61 5C 66 1C B3 26 1C 2E 11 0D 19 BD DC 08 1A 90 00 20 00 24
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
21 B6 2F 58 37 87 7B 3F EE D9
8A 73 EE 69 BF E0 0D 5C 57 EF
F7 4F A7 18 4D 76 EB EB 3E AA
2B 79 C3 27 A6 C6 DB D3 17 EA
37 39 BF 0C B6 2C 9A F5 04 40
CF 3F 25 CB C1 25 08 0F 1F D2
44 57 2E 47 F9 CC A0 03 E3 60
11 20
18 4D 76 EB EB 3E AA 3D C2 19 D3 EE 77 BF C1 38 FF C4 07 C0
27 A6 C6 DB D3 17 EA CD 74 BC E5 42 36 F8 D2 86 F9 E9 86 AA
0C B6 2C 9A F5 04 40 BB D8 FD B4 97 2A 9A A6 D1 9E 2A 60 23
CB C1 25 08 0F 1F D2 34 C4 61 27 2E 7B E9 00 FD 86 77 E9 AF
47 F9 CC A0 03 E3 60 C2 DF C1 F5 6C 59 0E 99 64 3D 7D E7 75
3B DF 1C DC 61 5C 66 1C B3 26 1C 2E 11 0D 19 BD DC 08 1A 90
CD 02 DD E6 49 6F 53 E2 2C 34 10 EA 1A 44 B4 49 7E D5 B6 CB
F1 FF 24 33 5D 8F D4 26 2E C4 FD 81 FB 96 36 51 F1 38 BE 1E
06 99 4F 99 3F 45 DB DA 14 BE 53 D7 B2 2D 64 7B 10 74 0E 70
F3 25 4D EB 3F 68 72 10 3B 56 F2 A7 C4 A4 28 AE 16 D0 13 CC
04 39 A8 13 3C 1F 00 57 24 2A FD EA FC EB 77 B8 E1 7D DF 0D
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 16ms
memory: 142332kb
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:
52 33 39 73 4A 5A AA E0 86 96 4B 0B 83 A0 FA 82 9B B0 6E DC 03 1C B9 5B 81 EC C9 BE 91 3B DF 1C DC 61 5C 66 1C B3 26 1C 2E 11 0D 19 BD DC 08 1A 90 00 20 00 24
input:
parts 52 33 39 73 4A 5A AA E0 86 96 4B 0B 83 A0 FA 82 9B B0 6E DC 03 1C B9 5B 81 EC C9 BE 91 3B DF 1C DC 61 5C 66 1C B3 26 1C 2E 11 0D 19 BD DC 08 1A 90 00 20 00 24 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 21 B6 2F 58 37 87 7B 3F EE D9 8A 73 E...
output:
1 2 6 5
result:
ok correct answer
Test #2:
score: 100
Accepted
time: 24ms
memory: 142132kb
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:
44 85 C4 91 58 77 23 A9 E5 44 8E 28 DC A2 51 13 AE 4E 3C 21 62 9D 33 62 48 62 6C AB B1 4C C0 11 B6 DE 71 C2 E9 7B C2 3E 00 00 20 00 20
input:
parts 44 85 C4 91 58 77 23 A9 E5 44 8E 28 DC A2 51 13 AE 4E 3C 21 62 9D 33 62 48 62 6C AB B1 4C C0 11 B6 DE 71 C2 E9 7B C2 3E 00 00 20 00 20 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 AC DB B0 FB 26 E6 12 36 37 F1 6...
output:
6 6
result:
ok correct answer
Test #3:
score: 0
Wrong Answer
time: 19ms
memory: 142352kb
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:
44 12 4F 58 0D 8B AB 72 D1 55 0F FC 74 28 E3 B0 02 9E FA 18 C0 18 AE 6C 74 6C 58 52 A4 19 00 61 07 33 D1 BE BA 3E 08 11 C9 00 20 00 20
input:
parts 44 12 4F 58 0D 8B AB 72 D1 55 0F FC 74 28 E3 B0 02 9E FA 18 C0 18 AE 6C 74 6C 58 52 A4 19 00 61 07 33 D1 BE BA 3E 08 11 C9 00 20 00 20 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 54 7D 03 92 36 85 D0 C0 B1 14 A...
output:
1 1 11 11 1 11 11 1 1 1 11 1 1 1 1 1 1 11 1 11 1 1 1 1
result:
wrong answer wrong answer on query 8: read (1, 1) but expected (1, 11)