QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#449107#4826. Find the Partsrizynvu0 28ms191328kbC++142.6kb2024-06-20 17:24:312024-06-20 17:24:32

Judging History

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

  • [2024-06-20 17:24:32]
  • 评测
  • 测评结果:0
  • 用时:28ms
  • 内存:191328kb
  • [2024-06-20 17:24:31]
  • 提交

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 = 1; 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 = 10; 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;
}

详细

Test #1:

score: 100
Accepted
time: 23ms
memory: 191080kb

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 7B 44 57 2E 47 F9 CC A0 03 E3 60 C2 DF C1 F5 6C 59 0E 99 64 3D 7D E7 75 C1 C4 8B 1A 77 E1 D2 4D 06 42 07 A3 1A 67 EC F1 B2 08 96 F6 C3 4E 79 E9 

input:

parts
50
00 18 7B 44 57 2E 47 F9 CC A0 03 E3 60 C2 DF C1 F5 6C 59 0E 99 64 3D 7D E7 75 C1 C4 8B 1A 77 E1 D2 4D 06 42 07 A3 1A 67 EC F1 B2 08 96 F6 C3 4E 79 E9
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
6 5

result:

ok correct answer

Test #2:

score: 100
Accepted
time: 20ms
memory: 191328kb

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:

42
00 14 2F F6 21 93 0D AC DB B0 FB 26 E6 12 36 37 F1 6B 08 50 9C 4B E7 7E 59 83 38 FC 89 01 57 EE 2D FB AC E3 A0 B8 95 8F 05 7D 

input:

parts
42
00 14 2F F6 21 93 0D AC DB B0 FB 26 E6 12 36 37 F1 6B 08 50 9C 4B E7 7E 59 83 38 FC 89 01 57 EE 2D FB AC E3 A0 B8 95 8F 05 7D
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
6C AB B...

output:

6 6

result:

ok correct answer

Test #3:

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

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:

42
00 14 88 0B D3 2A A8 91 60 A9 19 9C 17 15 E2 A1 8F 38 EB 30 81 D3 01 26 C8 54 09 77 0A 18 85 17 88 EC F3 49 34 02 9D C0 ED 9E 

input:

parts
42
00 14 88 0B D3 2A A8 91 60 A9 19 9C 17 15 E2 A1 8F 38 EB 30 81 D3 01 26 C8 54 09 77 0A 18 85 17 88 EC F3 49 34 02 9D C0 ED 9E
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
A7 42 3...

output:

1 1
11 11
1 11
11 1
1 1
11 1
1 1
0
-1 -1
0
-1 -1

result:

wrong answer wrong answer on query 8: read (0, -1) but expected (1, 11)