QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302172#4826. Find the Partsisaunoya0 0ms0kbC++142.1kb2024-01-10 17:07:162024-01-10 17:07:17

Judging History

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

  • [2024-01-10 17:07:17]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-01-10 17:07:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> pos[65536];
int a[2005][2005];

int get(char c) {
  if (isdigit(c)) {
    return c - 48;
  } else {
    return c - 'A' + 10;
  }
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  if (s == "message") {
    int h, w;
    cin >> h >> w;
    cout << ((h + 9) / 10) * w + 4 << "\n";
    cout << (h / 100) << " " << (h % 100) << " ";
    cout << (w / 100) << " " << (w % 100) << " ";
    for (int i = 0; i < h; i++) {
      vector<string> s;
      for (int j = 0; j < w; j++) {
        string str;
        cin >> str;
        s.push_back(str);
      }
      if (i % 10 == 0) {
        for (auto str : s) {
          cout << str << " ";
        }
      }
    }
  } else {
    int sz;
    cin >> sz;
    int h1, h2, w1, w2;
    cin >> h1 >> h2 >> w1 >> w2;
    int h = h1 * 100 + h2;
    int w = w1 * 100 + w2;
    sz -= 4;
    for (int i = 0; i < h; i += 10) {
      vector<int> tmp;
      for (int j = 0; j < w; j++) {
        string s;
        cin >> s;
        int c = get(s[0]) * 16 + get(s[1]);
        a[i][j] = c;
        tmp.emplace_back(c);
      }
      for (int j = 0; j < w - 1; j++) {
        int c0 = tmp[j];
        int c1 = tmp[j + 1];
        int val = c0 * 256 + c1;
        assert(0 <= val && val < 65536);
        pos[val].emplace_back(i, j);
      }
    }
    int q;
    cin >> q;
    while (q--) {
      int h, w;
      cin >> h >> w;
      for (int i = 0; i < h; i++) {
        vector<int> tmp;
        for (int j = 0; j < w; j++) {
          string s;
          cin >> s;
          int c = get(s[0]) * 16 + get(s[1]);
          tmp.emplace_back(c);
        }
        int t = tmp[0] * 256 + tmp[1];
        for (auto [x, y] : pos[t]) {
          bool ok = true;
          for (int j = 2; j < w; j++) {
            if (a[x][y + j] != tmp[j]) {
              ok = false;
              break;
            }
          }
          if (ok) {
            cout << x - i + 1 << " " << y + 1 << "\n";
            break;
          }
        }
      }
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer on the first run

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
0 20 0 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 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:


output:


result:

wrong answer Token "0" doesn't correspond to pattern "[0123456789ABCDEF]{2,2}"