QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#321730 | #4826. Find the Parts | Skyan | 0 | 21ms | 142352kb | C++23 | 2.9kb | 2024-02-05 11:00:31 | 2024-02-05 11:00:32 |
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 = 1e16;
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, flag = 0;
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) && flag == 0) {
pair<int, int> p = mm[x][c];
int h = p.first, k = p.second;
cout << h - i + 1 << " " << k << '\n';
flag = 1;
}
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 20ms
memory: 142132kb
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: 20ms
memory: 142352kb
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: 100
Accepted
time: 15ms
memory: 142096kb
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 11 1 1
result:
ok correct answer
Test #4:
score: 0
Wrong Answer
time: 21ms
memory: 142172kb
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:
189 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 3D 26 BD 80 99 4B D6 83 9A DC 4D D7 F4 BA DB 0D 2E 55 59 48 33 CC B4 FE 82 A8 B2 F8 D4 34 5B 0D E1 A0 95 ED 1B 3C B1 DC 41 80 49 5B B6 72 E5 FC C1 CF 9E 20 51 01 87 E9 60 A4 54 D1 01 6A...
input:
parts 189 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 3D 26 BD 80 99 4B D6 83 9A DC 4D D7 F4 BA DB 0D 2E 55 59 48 33 CC B4 FE 82 A8 B2 F8 D4 34 5B 0D E1 A0 95 ED 1B 3C B1 DC 41 80 49 5B B6 72 E5 FC C1 CF 9E 20 51 01 87 E9 60 A4 54 D1...
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 9 12 16 18 12 11 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 21 1...
result:
wrong answer wrong answer on query 24: read (6, 12) but expected (32, 14)