QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#321409#8217. King's Dinnerhos_lyricAC ✓1ms3708kbC++144.2kb2024-02-04 17:14:362024-02-04 17:14:38

Judging History

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

  • [2024-02-04 17:14:38]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3708kb
  • [2024-02-04 17:14:36]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


int N;
char ans[110][110];

vector<pair<int, int>> tate, yoko;
void solve(int m, int n) {
  if (m > 7) {
    solve(m - 6, n);
    for (int a = 0; a <= n/2; ++a) if ((n - 2*a) % 3 == 0) {
      const int b = (n - 2*a) / 3;
      int y = 0;
      for (int i = 0; i < a; ++i) {
        tate.emplace_back(m - 6, y);
        tate.emplace_back(m - 3, y);
        y += 2;
      }
      for (int i = 0; i < b; ++i) {
        yoko.emplace_back(m - 6, y);
        yoko.emplace_back(m - 4, y);
        yoko.emplace_back(m - 2, y);
        y += 3;
      }
      assert(y == n);
      return;
    }
    assert(false);
  } else if (n > 7) {
    solve(m, n - 6);
    for (int a = 0; a <= m/2; ++a) if ((m - 2*a) % 3 == 0) {
      const int b = (m - 2*a) / 3;
      int x = 0;
      for (int i = 0; i < a; ++i) {
        yoko.emplace_back(x, n - 6);
        yoko.emplace_back(x, n - 3);
        x += 2;
      }
      for (int i = 0; i < b; ++i) {
        tate.emplace_back(x, n - 6);
        tate.emplace_back(x, n - 4);
        tate.emplace_back(x, n - 2);
        x += 3;
      }
      assert(x == m);
      return;
    }
    assert(false);
  } else {
    assert(m == n);
    if (m == 2) {
      //
    } else if (m == 3) {
      tate.emplace_back(0, 0);
    } else if (m == 4) {
      tate.emplace_back(0, 0);
      tate.emplace_back(0, 2);
    } else if (m == 5) {
      tate.emplace_back(0, 0);
      tate.emplace_back(2, 3);
      yoko.emplace_back(0, 2);
      yoko.emplace_back(3, 0);
    } else if (m == 6) {
      for (int x = 0; x < m; x += 3) for (int y = 0; y < n; y += 2) {
        tate.emplace_back(x, y);
      }
    } else if (m == 7) {
      tate.emplace_back(0, 0);
      tate.emplace_back(0, 2);
      tate.emplace_back(4, 3);
      tate.emplace_back(4, 5);
      yoko.emplace_back(0, 4);
      yoko.emplace_back(2, 4);
      yoko.emplace_back(3, 0);
      yoko.emplace_back(5, 0);
    } else {
      assert(false);
    }
  }
}

int main() {
  for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
    scanf("%d", &N);
    
    tate.clear();
    yoko.clear();
    solve(N + 1, N + 1);
    
    for (int x = 0; x < N; ++x) {
      fill(ans[x], ans[x] + N, '.');
      ans[x][N] = 0;
    }
    for (const auto &p : tate) {
      for (int d = 0; d < 2; ++d) {
        const int x = p.first + d;
        const int y = p.second;
        assert(0 <= x); assert(x < N);
        assert(0 <= y); assert(y < N);
        ans[x][y] = '#';
      }
    }
    for (const auto &p : yoko) {
      for (int d = 0; d < 2; ++d) {
        const int x = p.first;
        const int y = p.second + d;
        assert(0 <= x); assert(x < N);
        assert(0 <= y); assert(y < N);
        ans[x][y] = '#';
      }
    }
    
    for (int x = 0; x < N; ++x) {
      puts(ans[x]);
    }
cerr<<string(80,'=')<<endl;
  }
#ifndef LOCAL
  break;
#endif
  }
  return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3696kb

input:

3
1
2
3

output:

.
#.
#.
#.#
#.#
...

result:

ok all tests correct (3 test cases)

Test #2:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

50
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

output:

.
#.
#.
#.#
#.#
...
#.##
#...
...#
##.#
#.#.#
#.#.#
.....
#.#.#
#.#.#
#.#.##
#.#...
....##
##....
...#.#
##.#.#
..##.##
.......
#.##.##
#......
..##.##
#......
#.##.##
#..#.#.#
#..#.#.#
........
##.##.##
........
##.##.##
........
##.##.##
#.#.##.##
#.#......
....##.##
.........
#.#.##.##
#.#......
...

result:

ok all tests correct (50 test cases)

Test #3:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

39
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

output:

#.#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##
#.#................................................
....##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##
...................................................
#.#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##
#.#........................................

result:

ok all tests correct (39 test cases)

Test #4:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

11
90
91
92
93
94
95
96
97
98
99
100

output:

#.#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##
#.#.......................................................................................
....##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##
##............................

result:

ok all tests correct (11 test cases)

Test #5:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

1
100

output:

#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##
#...................................................................................................
...#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed