QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619035#2446. Block BreakerPlentyOfPenalty#AC ✓166ms27072kbC++201.6kb2024-10-07 12:39:282024-10-07 12:39:29

Judging History

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

  • [2024-10-07 12:39:29]
  • 评测
  • 测评结果:AC
  • 用时:166ms
  • 内存:27072kb
  • [2024-10-07 12:39:28]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) begin(x), end(x)
#ifdef memset0
#define log(...) fprintf(stderr, __VA_ARGS__)
#else
#define endl '\n'
#define log(...) (void(0))
#endif
using namespace std;
using ll = long long;
using lf = long double;
using ull = unsigned long long;

const int N = 2e3 + 9;
int T, n, m, q;
bool a[N][N], b[N][N][4], inq[N][N];
queue<pair<int, int>> que;

void trans(int x, int y, int w) {
  if (x < 1 || y < 1 || x > n || y > m) {
    return;
  }
  if (!a[x][y] || inq[x][y]) {
    return;
  }
  // log("trans %d %d %d\n", x, y, w);
  b[x][y][w] = 0;
  if ((b[x][y][0] == false || b[x][y][1] == false) && (b[x][y][2] == false || b[x][y][3] == false)) {
    inq[x][y] = true;
    que.push(make_pair(x, y));
  }
}

void fall(int x, int y) {
  a[x][y] = 0;
  trans(x - 1, y, 0), trans(x + 1, y, 1);
  trans(x, y - 1, 2), trans(x, y + 1, 3);
}

int main() {
#ifdef memset0
  freopen("I.in", "r", stdin);
#endif
  cin.tie(0)->sync_with_stdio(0);
  cin >> T;
  while (T--) {
    cin >> n >> m >> q;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        a[i][j] = b[i][j][0] = b[i][j][1] = b[i][j][2] = b[i][j][3] = 1;
        inq[i][j] = 0;
      }
    }
    for (int x, y, i = 1; i <= q; i++) {
      int cnt = 0;
      cin >> x >> y;
      if (a[x][y]) {
        ++cnt;
        fall(x, y);
        while (que.size()) {
          ++cnt;
          auto [x, y] = que.front();
          que.pop();
          fall(x, y);
        }
      }
      cout << cnt << endl;
    }
  }
}

詳細信息

Test #1:

score: 100
Accepted
time: 166ms
memory: 27072kb

input:

10
1 1 2
1 1
1 1
1 2 5
1 2
1 2
1 1
1 2
1 1
1651 1852 69820
938 1459
98 243
1504 554
725 245
601 587
1465 1687
1037 1172
433 1112
173 493
1175 278
302 558
1326 633
375 1043
495 1673
1275 1672
1629 1299
1588 432
507 1754
953 270
1475 1805
1343 1096
798 1633
1124 809
525 1163
1201 1633
1381 578
1489 89...

output:

1
0
1
0
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 576535 lines