Submission #531597

# Submission time Handle Problem Language Result Execution time Memory
531597 2022-03-01T06:00:53 Z eecs L-triominoes (CEOI21_ltriominoes) C++17
0 / 100
5 ms 1348 KB
#include <bits/stdc++.h>
using namespace std;

int W, H, K, x[250], y[250];
bool f[1 << 13], g[1 << 13];
vector<array<int, 2>> E;

int main() {
    scanf("%d %d %d", &W, &H, &K);
    vector<int> pos = {1, H};
    for (int S = 0; S < 1 << W; S++) {
        function<void(int, int)> dfs = [&](int i, int T) {
            if (i == W) { E.push_back({S, T}); return; }
            if (S >> i & 1) return dfs(i + 1, T);
            if (i && !(T >> (i - 1) & 1) && !(T >> i & 1)) dfs(i + 1, T | (1 << (i - 1)) | (1 << i));
            if (i + 1 == W) return;
            if (!(T >> i & 1) && !(T >> (i + 1) & 1)) dfs(i + 1, T | (1 << i) | (1 << (i + 1)));
            if (!(S >> (i + 1) & 1) && !(T >> i & 1)) dfs(i + 2, T | (1 << i));
            if (!(S >> (i + 1) & 1) && !(T >> (i + 1) & 1)) dfs(i + 2, T | (1 << (i + 1)));
        };
        dfs(0, 0);
    }
    for (int i = 0; i < K; i++) {
        scanf("%d %d", &x[i], &y[i]), pos.push_back(y[i]);
    }
    sort(pos.begin(), pos.end());
    pos.resize(unique(pos.begin(), pos.end()) - pos.begin());
    f[0] = 1;
    for (int i = 0; i < pos.size(); i++) {
        memset(g, 0, sizeof(g));
        int S = 0;
        for (int j = 0; j < K; j++) {
            if (pos[i] == y[j]) S |= 1 << (x[j] - 1);
        }
        for (int j = 0; j < 1 << W; j++) {
            if (!(j & S)) g[j | S] |= f[j];
        }
        swap(f, g);
        if (i == pos.size() - 1) break;
        int n = pos[i + 1] - pos[i];
        if (n >= 6) n %= 6;
        for (int $ = 0; $ < n; $++) {
            memset(g, 0, sizeof(g));
            for (auto &e : E) g[e[1]] |= f[e[0]];
            swap(f, g);
        }
    }
    puts(f[(1 << W) - 1] ? "YES" : "NO");
    return 0;
}

Compilation message

ltrominoes.cpp: In function 'int main()':
ltrominoes.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < pos.size(); i++) {
      |                     ~~^~~~~~~~~~~~
ltrominoes.cpp:39:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         if (i == pos.size() - 1) break;
      |             ~~^~~~~~~~~~~~~~~~~
ltrominoes.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d %d", &W, &H, &K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ltrominoes.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%d %d", &x[i], &y[i]), pos.push_back(y[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 5 ms 1348 KB Output is correct
6 Incorrect 2 ms 840 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 204 KB Output is correct
2 Incorrect 5 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 204 KB Output is correct
2 Incorrect 3 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -