QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#449209#4826. Find the Partsrizynvu0 48ms222368kbC++142.4kb2024-06-20 20:07:122024-06-20 20:07:13

Judging History

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

  • [2024-06-20 20:07:13]
  • 评测
  • 测评结果:0
  • 用时:48ms
  • 内存:222368kb
  • [2024-06-20 20:07:12]
  • 提交

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::unordered_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++) {
               if (! son[now][to256(S[k])]) son[now][to256(S[k])] = ++tot;
               now = son[now][to256(S[k])];
            }
            son[now][0] = h, son[now][1] = j - i + 1;
         }
      }
      int Q; std::cin >> Q;
      while (Q--) {
         int h, w; std::cin >> h >> w;
         std::vector<std::string> T(w);
         int ansx = -1, ansy = -1;
         for (int i = 0; i < h; i++) {
            for (auto &x : T) std::cin >> x;
            if (ansx != -1) {
               int now = 0;
               for (int j = 0; j < 10; j++) {
                  if (! son[now].count(to256(T[j]))) {now = 0; break;}
                  else now = son[now][to256(T[j])];
               }
               if (now) ansx = son[now][0] - i, ansy = son[now][1];
            }
         }
         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: 48ms
memory: 222368kb

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 -1
-1 -1

result:

wrong answer wrong answer on query 1: read (-1, -1) but expected (1, 2)