QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#589360#5414. Stop, Yesterday Please No MoreLuckyblockWA 0ms3924kbC++202.4kb2024-09-25 17:25:222024-09-25 17:25:22

Judging History

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

  • [2024-09-25 17:25:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3924kb
  • [2024-09-25 17:25:22]
  • 提交

answer

//
/*
By:Luckyblock
*/
#include <bits/stdc++.h>
#define LL long long
const int kN = 2e3 + 10;
//=============================================================
int n, m, k;
std::string s;
int cnt[kN << 1][kN << 1];
int d, len, delta[5];
std::map <char, int> ex, ey;
//=============================================================
void init() {
  d = std::max(n, m) + 2;
  for (int i = -n - 2; i <= n + 2; ++ i) {
    for (int j = -m - 2; j <= m + 2; ++ j) {
      cnt[i + d][j + d] = 0;
    }
  }

  len = s.length() - 1;
  cnt[0 + d][0 + d] = 1;
  delta[0] = delta[1] = delta[2] = delta[3] = 0;
  int x = 0, y = 0;
  for (int i = 1; i <= len; ++ i) {
    x -= ex[s[i]], y -= ey[s[i]];
    delta[0] = std::min(delta[0], x);
    delta[1] = std::max(delta[1], x);
    delta[2] = std::min(delta[2], y);
    delta[3] = std::max(delta[3], y);

    if (x > - n && y > - m && x < n && y < m) {
      cnt[x + d][y + d] = 1;
    }
  }
  for (int i = -n; i <= n; ++ i) {
    for (int j = -m; j <= m; ++ j) {
      cnt[i + d][j + d] += cnt[i - 1 + d][j + d] + 
                           cnt[i + d][j - 1 + d] -
                           cnt[i - 1 + d][j - 1 + d];
    }
  }
}
//=============================================================
int main() {
  // freopen("1.txt", "r", stdin);
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  ex['U'] = -1, ex['D'] = 1, ex['L'] = 0, ex['R'] = 0;
  ey['U'] = 0, ey['D'] = 0, ey['L'] = -1, ey['R'] = 1;

  int T; std::cin >> T;
  while (T --) {
    std::cin >> n >> m >> k;
    std::cin >> s; s = "$" + s;
    init();

    int ans = 0; 
    int c1 = (n + delta[0] - delta[1]) * (m + delta[2] - delta[3]);
    if (c1 <= 0) {
      std::cout << (k == 0 ? n * m : 0) << "\n";
      continue;
    }

    for (int i = 1; i <= n; ++ i) {
      for (int j = 1; j <= m; ++ j) {
        int c3 = cnt[(n - i) + delta[0] + d][(m - j) + delta[2] + d] - 
                 cnt[(n - i) + delta[0] + d][-(j - 1) - 1 + delta[3] + d] - 
                 cnt[-(i - 1) - 1 + delta[1] + d][(m - j) + delta[2] + d] + 
                 cnt[-(i - 1) - 1 + delta[1] + d][-(j - 1) - 1 + delta[3] + d];
        // c3 = c2 - c3;
        if (c1 - c3 == k) {
          ++ ans;
          std::cout << i << " " << j << "\n";
        }
      }
    }
    std::cout << ans << "\n";
  }
  return 0;
}
/*
1
3 3 4
LU

1
4 5 0
UUUUUUU

1
4 5 3
ULDDRR
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3924kb

input:

3
4 5 3
ULDDRR
4 5 0
UUUUUUU
4 5 10
UUUUUUU

output:

3 4
4 3
2
20
0

result:

wrong answer 1st numbers differ - expected: '2', found: '3'