QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#470467#6398. Puzzle: TapaUESTC_Snow_Halation#WA 0ms3644kbC++142.6kb2024-07-10 14:00:302024-07-10 14:00:31

Judging History

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

  • [2024-07-10 14:00:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3644kb
  • [2024-07-10 14:00:30]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
constexpr int max_n = 500;
double eps = 1e-9;

char mp[max_n][max_n];
int n, m;

bool check(int x, int y, bool inner) {
    if (inner && (mp[x][y] == '2' || mp[x][y] == '4')) return false;
    if (!inner && (mp[x][y] == '7')) return false;
    if (mp[x][y] == '3' || mp[x][y] == '5' || mp[x][y] == '8') return false;
    if (x && mp[x - 1][y] == '.') return false;
    if (y && mp[x][y - 1] == '.') return false;
    if (x < n*2 - 1 && mp[x + 1][y] == '.') return false;
    if (y < m*2-1 && mp[x][y + 1] == '.') return false;
    return true;
}

void solve() {
    cin >> n >> m;
    for (int i = 1; i < 2 * n; ++i) {
        for (int j = 1; j < 2 * m; ++j) {
            cin >> mp[i][j];
            if (mp[i][j] == '.') {
                mp[i][j] = '#';
            }
        }
    }
    for (int i = 1; i < n * 2; i+=2) {
        for (int j = 1; j < m * 2; j+=2) {
            if (check(i, j, false)) {
                if (i + 2 < n*2 && check(i + 2, j, false)) {
                    mp[i + 1][j] = '.';
                } else if (j + 2 < m * 2 && check(i, j + 2, false)) {
                  mp[i][j + 1] = '.';
                } else if (i - 2 > 0 && check(i - 2, j, false)) {
                  mp[i - 1][j] = '.';
                } else if (j - 2 > 0 && check(i, j - 2, false)) {
                  mp[i][j - 1] = '.';
                } else {
                  cout << "NO\n";
                  return;
                }
            }
            if (check(i, j, true)) {
              if (i + 2 <= n*2 && check(i + 2, j, true)) {
                mp[i + 1][j] = '.';
              } else if (j + 2 <= m * 2 && check(j + 2, j, true)) {
                mp[i][j + 1] = '.';
              } else if (i - 2 > 0 && check(i - 2, j, true)) {
                mp[i - 1][j] = '.';
              } else if (j - 2 > 0 && check(i, j - 2, true)) {
                mp[i][j - 1] = '.';
              }else {
                cout << "NO\n";
                return;
              }
            }
        }
    }
    cout << "YES\n";
    for (int i = 1; i < 2 * n; ++i) {
      for (int j = 1; j < 2 * m; ++j) {
        cout << mp[i][j];
      }
      cout << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
//    cin >> T;
//    scanf("%d", &T);
    for (int i = 1; i <= T; ++i) {
        // cout << "Case " << i << ": ";
        solve();
    }
    return 0;
}

/*
3 3
2.4.3
.....
5.8.5
.....
3.5.3
*/

详细

Test #1:

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

input:

3 3
2.4.3
.....
5.8.5
.....
3.5.3

output:

YES
2.4#3
#####
5#8#5
#####
3#5#3

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

3 3
3.4.3
.....
5.7.5
.....
3.5.3

output:

NO

result:

ok Correct.

Test #3:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

2 2
2.2
...
2.2

output:

YES
2#2
.#.
2#2

result:

ok Correct.

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3628kb

input:

2 50
2.4.4.4.4.5.5.5.5.5.5.5.5.4.5.5.4.4.5.5.5.5.4.5.5.5.5.5.4.4.5.4.5.5.5.5.5.5.5.5.5.5.5.4.4.5.5.4.5.3
...................................................................................................
2.5.5.4.4.5.5.5.4.4.5.5.5.4.5.5.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.4.4.4.5.5.5.5.5.5.5.4.4.5.5.5.5.4...

output:

YES
2#4.4#4#4#5#5#5#5#5#5#5#5#4#5#5#4.4#5#5#5#5#4#5#5#5#5#5#4.4#5#4#5#5#5#5#5#5#5#5#5#5#5#4.4#5#5#4#5#3
.#####.#.#################.#################.#################.###############################.####
2#5#5#4#4#5#5#5#4.4#5#5#5#4#5#5#5#5#5#5#5#5#4#4.4#5#5#5#5#5#5#4#4.4#5#5#5#5#5#5#5#4.4#5#5#5#5#4#...

result:

wrong answer Clue not satisfied at (1,7), non-consecutive shaded cells