QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#320269#8217. King's Dinnerucup-team133#WA 1ms3844kbC++231.9kb2024-02-03 15:03:362024-02-03 15:03:37

Judging History

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

  • [2024-02-03 15:03:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3844kb
  • [2024-02-03 15:03:36]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void(0)
#endif

using namespace std;

typedef long long ll;
#define all(x) begin(x), end(x)
constexpr int INF = (1 << 30) - 1;
constexpr long long IINF = (1LL << 60) - 1;
constexpr int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

template <class T> istream& operator>>(istream& is, vector<T>& v) {
    for (auto& x : v) is >> x;
    return is;
}

template <class T> ostream& operator<<(ostream& os, const vector<T>& v) {
    auto sep = "";
    for (const auto& x : v) os << exchange(sep, " ") << x;
    return os;
}

template <class T, class U = T> bool chmin(T& x, U&& y) { return y < x and (x = forward<U>(y), true); }

template <class T, class U = T> bool chmax(T& x, U&& y) { return x < y and (x = forward<U>(y), true); }

template <class T> void mkuni(vector<T>& v) {
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));
}

template <class T> int lwb(const vector<T>& v, const T& x) { return lower_bound(begin(v), end(v), x) - begin(v); }

void solve() {
    int n;
    cin >> n;

    if (n == 1) {
        cout << ".\n";
        return;
    }
    vector<string> ans(n, string(n, '.'));
    if (n & 1) {
        for (int j = 0; j < n; j += 2) ans[0][j] = ans[1][j] = '#';
        for (int i = 3; i < n; i += 2) {
            for (int j = 0; j < n; j++) {
                int ni = (i - 3) / 2, nj = j;
                if ((ni + nj) & 1) continue;
                ans[i][j] = ans[i + 1][j] = '#';
            }
        }
    } else {
        for (int i = 0; i < n; i += 2) {
            for (int j = 0; j < n; j++) {
                int ni = i / 2, nj = j;
                if ((ni + nj) & 1) continue;
                ans[i][j] = ans[i + 1][j] = '#';
            }
        }
    }

    for (int i = 0; i < n; i++) cout << ans[i] << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    for (; t--;) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3844kb

input:

3
1
2
3

output:

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

result:

ok all tests correct (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3832kb

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:

wrong answer grid contains two dominoes that are adjacent (test case 4)