QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100850#1806. Character Gridckiseki#AC ✓3ms3276kbC++20968b2023-04-28 13:10:182023-04-28 13:10:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-28 13:10:19]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3276kb
  • [2023-04-28 13:10:18]
  • 提交

answer

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

char a[13][14];

set<pair<char, char>> s;
bool dfs(int i, int j) {
    if (j == 13) {
        return dfs(i + 1, 0);
    } else if (i == 13) {
        return true;
    } else {
        for (int x = 0; x < 13; ++x) {
            a[i][j] = x + (i & 1) * 13 + 'a';
            if (i and s.find({a[i - 1][j], a[i][j]}) != s.end())
                continue;
            if (j and s.find({a[i][j - 1], a[i][j]}) != s.end())
                continue;
            if (i) s.emplace(a[i - 1][j], a[i][j]);
            if (j) s.emplace(a[i][j - 1], a[i][j]);
            if (dfs(i, j + 1)) return true;
            if (i) s.erase({a[i - 1][j], a[i][j]});
            if (j) s.erase({a[i][j - 1], a[i][j]});
        }
        return false;
    }
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cout << 13 << '\n';
    assert(dfs(0, 0));
    for (int i = 0; i < 13; ++i)
        cout << a[i] << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3276kb

input:



output:

13
aabacadaeafag
nonpnqnrnsntn
ahbbcbdbebfbg
unuoopoqoroso
aibiajbhccdce
vnvownwotppqp
akbjalbkamcfd
xnxoynyoznzpr
bmdfchdgcjded
touqrpspuptqq
clcgefegdheci
sqvqsrrsvrtwp
ddiehfgffhgga

result:

ok accepted