QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#449109 | #4826. Find the Parts | rizynvu | 0 | 27ms | 191092kb | C++14 | 2.6kb | 2024-06-20 17:25:41 | 2024-06-20 17:25:41 |
Judging History
answer
#include<bits/stdc++.h>
namespace First {
inline char to16(int x) {
return x < 10 ? (x + '0') : (x - 10 + 'A');
}
inline std::string to256(int x) {
return std::string("") + to16(x / 16) + to16(x % 16);
}
inline void main() {
int n, m;
std::cin >> n >> m;
std::vector<std::string> ans;
ans.push_back(to256(m / 256)), ans.push_back(to256(m % 256));
for (int i = 0; i < n; i++)
for (int j = 1; j <= m; j++) {
std::string s;
std::cin >> s;
if (i % 10 == 0) ans.push_back(s);
}
std::cout << ans.size() << '\n';
for (auto x : ans) std::cout << x << ' ';
}
}
namespace Second {
inline int to16(char x) {
return x >= 'A' ? (x - 'A' + 10) : (x - '0');
}
inline int to256(std::string x) {
return to16(x[0]) * 16 + to16(x[1]);
}
const int maxn = 2000 * 200 * 10 + 10;
std::map<int, int> son[maxn];
inline void main() {
int len; std::cin >> len;
std::vector<std::string> S(len);
for (auto &x : S) std::cin >> x;
int m = to256(S[0]) * 256 + to256(S[1]);
int tot = 0;
for (int i = 2, h = 1; i < S.size(); i += m, h += 10) {
for (int j = i; j + 10 <= i + m; j++) {
int now = 0;
for (int k = j; k < j + 10; k++) {
int &u = son[now][to256(S[k])];
now = u = ! u ? ++tot : u;
}
son[now][0] = h, son[now][1] = j - i + 1;
}
}
int Q; std::cin >> Q;
while (Q--) {
int h, w; std::cin >> h >> w;
int ansx = -1, ansy = -1;
bool f = 0;
for (int i = 0; i < h; i++) {
std::vector<std::string> T(w);
for (auto &x : T) std::cin >> x;
for (int j = 0; j + 10 <= w; j++) {
int now = 0;
for (int k = j; k < j + 10; k++) {
now = son[now][to256(T[k])];
if (! now) break;
}
if (now) {
f = 1;
ansx = son[now][0] - i, ansy = son[now][1];
break;
}
}
if (ansx != -1)
break;
}
if (ansx == -1) std::cout << f << '\n';
std::cout << ansx << ' ' << ansy << '\n';
}
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0), std::cout.tie(0);
std::string s; std::cin >> s;
s == "message" ? First::main() : Second::main();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 27ms
memory: 191092kb
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:
50 00 18 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
input:
parts 50 00 18 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 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 B...
output:
1 2 0 -1 -1
result:
wrong answer wrong answer on query 2: read (0, -1) but expected (6, 5)