Submission #200893

# Submission time Handle Problem Language Result Execution time Memory
200893 2020-02-08T12:35:48 Z SamAnd Tetris (COCI17_tetris) C++17
48 / 80
5 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 12, K = 11;
const int nn[K] = {2, 1, 4, 2, 3, 2, 3, 2, 3, 2, 3};
const int mm[K] = {2, 4, 1, 3, 2, 3, 2, 3, 2, 3, 2};
const pair<int, int> f[K][N] =
{
    {{0, 0}, {0, 1}, {1, 0}, {1, 1}},
    {{0, 0}, {0, 1}, {0, 2}, {0, 3}},
    {{0, 0}, {1, 0}, {2, 0}, {3, 0}},
    {{0, 1}, {0, 2}, {1, 0}, {1, 1}},
    {{0, 0}, {1, 0}, {1, 1}, {2, 1}},
    {{0, 0}, {0, 1}, {1, 1}, {1, 2}},
    {{0, 1}, {1, 0}, {1, 1}, {2, 0}},
    {{0, 1}, {1, 0}, {1, 1}, {1, 2}},
    {{0, 0}, {1, 0}, {1, 1}, {2, 0}},
    {{0, 0}, {0, 1}, {0, 2}, {2, 1}},
    {{0, 1}, {1, 0}, {1, 1}, {2, 1}}
};

int n, m;
char a[N][N];

int q[K];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i)
    {
        scanf(" %s", a[i]);
    }
    for (int u = 0; u < K; ++u)
    {
        for (int x = 0; x < n - nn[u] + 1; ++x)
        {
            for (int y = 0; y < m - mm[u] + 1; ++y)
            {
                bool z = true;
                for (int i = 0; i < 4; ++i)
                {
                    int hx = x + f[u][i].first;
                    int hy = y + f[u][i].second;
                    if (a[hx][hy] == '.')
                    {
                        z = false;
                        break;
                    }
                    if (a[hx][hy] != a[x + f[u][0].first][y + f[u][0].second])
                    {
                        z = false;
                        break;
                    }
                }
                if (z)
                    ++q[u];
            }
        }
    }
    printf("%d\n", q[0]);
    printf("%d\n", q[1] + q[2]);
    printf("%d\n", q[3] + q[4]);
    printf("%d\n", q[5] + q[6]);
    printf("%d\n", q[7] + q[8] + q[9] + q[10]);
    return 0;
}

Compilation message

tetris.cpp: In function 'int main()':
tetris.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
tetris.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s", a[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Incorrect 5 ms 256 KB Output isn't correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Incorrect 5 ms 256 KB Output isn't correct
8 Correct 5 ms 256 KB Output is correct
9 Incorrect 5 ms 256 KB Output isn't correct
10 Incorrect 5 ms 256 KB Output isn't correct