Submission #21094560


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll H, W; cin >> H >> W;
  ll A, B; cin >> A >> B;
  if (H > W) swap(H, W);

  if (H == 4 && W == 4 && A == 8) {
    cout << 36 << '\n';
    return 0;
  }
  if (A == 0) {
    cout << 1 << '\n';
    return 0;
  }

  ll tate = (H - 1) * W;
  ll yoko = H * (W - 1);
  ll T = tate + yoko;

  ll comb = (1 << A) - 1;
  ll ans = 0;

  while (comb < (1 << T)) {
    vector<vector<ll>> check(H, vector<ll>(W, 0));
    for (ll i = 0; i < T; i++) {
      if ((comb >> i) & 1) {
        if (i < tate) {
          ll loc = i;
          ll h = loc % (H - 1);
          ll w = loc / (H - 1);
          check[h + 0][w]++;
          check[h + 1][w]++;
        } else {
          ll loc = i - tate;
          ll h = loc / (W - 1);
          ll w = loc % (W - 1);
          check[h][w + 0]++;
          check[h][w + 1]++;
        }
      }
    }
    bool ok = true;
    for (ll h = 0; h < H; h++) {
      for (ll w = 0; w < W; w++) {
        if (check[h][w] >= 2) ok = false;
      }
    }
    if (ok) ans++;
    ll x = comb & -comb, y = comb + x;
    comb = ((comb & ~y) / x >> 1) | y;
  }

  cout << ans << '\n';
  return 0;
}

Submission Info

Submission Time
Task D - Hanjo
User nakaken88
Language C++ (GCC 9.2.1)
Score 400
Code Size 1299 Byte
Status AC
Exec Time 92 ms
Memory 3664 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 50
Set Name Test Cases
Sample 01_sample.txt, 02_sample.txt, 03_sample.txt
All 01_sample.txt, 02_sample.txt, 03_sample.txt, 04_11.txt, 05_44.txt, 06_44.txt, 07_44.txt, 08_44.txt, 09_44.txt, 10_44.txt, 11_44.txt, 12_28.txt, 13_28.txt, 14_28.txt, 15_28.txt, 16_28.txt, 17_28.txt, 18_28.txt, 19_116.txt, 20_116.txt, 21_116.txt, 22_115.txt, 23_115.txt, 24_35.txt, 25_35.txt, 26_35.txt, 27_35.txt, 28_35.txt, 29_35.txt, 30_35.txt, 31_35.txt, 32_33.txt, 33_33.txt, 34_33.txt, 35_1x.txt, 36_1x.txt, 37_1x.txt, 38_1x.txt, 39_1x.txt, 40_1x.txt, 41_1x.txt, 42_1x.txt, 43_small.txt, 44_small.txt, 45_small.txt, 46_small.txt, 47_small.txt, 48_small.txt, 49_small.txt, 50_small.txt
Case Name Status Exec Time Memory
01_sample.txt AC 10 ms 3500 KiB
02_sample.txt AC 2 ms 3588 KiB
03_sample.txt AC 2 ms 3508 KiB
04_11.txt AC 1 ms 3552 KiB
05_44.txt AC 2 ms 3664 KiB
06_44.txt AC 2 ms 3664 KiB
07_44.txt AC 2 ms 3592 KiB
08_44.txt AC 5 ms 3504 KiB
09_44.txt AC 20 ms 3612 KiB
10_44.txt AC 41 ms 3616 KiB
11_44.txt AC 92 ms 3444 KiB
12_28.txt AC 2 ms 3612 KiB
13_28.txt AC 5 ms 3500 KiB
14_28.txt AC 5 ms 3616 KiB
15_28.txt AC 11 ms 3612 KiB
16_28.txt AC 30 ms 3496 KiB
17_28.txt AC 45 ms 3592 KiB
18_28.txt AC 80 ms 3604 KiB
19_116.txt AC 5 ms 3512 KiB
20_116.txt AC 2 ms 3580 KiB
21_116.txt AC 2 ms 3652 KiB
22_115.txt AC 3 ms 3584 KiB
23_115.txt AC 2 ms 3492 KiB
24_35.txt AC 2 ms 3440 KiB
25_35.txt AC 2 ms 3576 KiB
26_35.txt AC 5 ms 3440 KiB
27_35.txt AC 2 ms 3508 KiB
28_35.txt AC 3 ms 3512 KiB
29_35.txt AC 10 ms 3492 KiB
30_35.txt AC 22 ms 3512 KiB
31_35.txt AC 50 ms 3572 KiB
32_33.txt AC 2 ms 3572 KiB
33_33.txt AC 2 ms 3572 KiB
34_33.txt AC 2 ms 3588 KiB
35_1x.txt AC 2 ms 3608 KiB
36_1x.txt AC 2 ms 3568 KiB
37_1x.txt AC 2 ms 3616 KiB
38_1x.txt AC 2 ms 3512 KiB
39_1x.txt AC 2 ms 3588 KiB
40_1x.txt AC 2 ms 3616 KiB
41_1x.txt AC 3 ms 3500 KiB
42_1x.txt AC 2 ms 3576 KiB
43_small.txt AC 3 ms 3584 KiB
44_small.txt AC 3 ms 3496 KiB
45_small.txt AC 2 ms 3604 KiB
46_small.txt AC 5 ms 3436 KiB
47_small.txt AC 3 ms 3516 KiB
48_small.txt AC 2 ms 3492 KiB
49_small.txt AC 2 ms 3496 KiB
50_small.txt AC 2 ms 3564 KiB