Submission #83349

# Submission time Handle Problem Language Result Execution time Memory
83349 2018-11-07T09:09:41 Z charlies_moo Spirale (COCI18_spirale) C++17
80 / 80
42 ms 676 KB
#include <cstdio>
#include <cstring>

int main() {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    int a[155][155];
    memset(a, 0, sizeof(a));
    int dx[2][4] = {{-1, 0, 1, 0}, {-1, 0, 1, 0}};
    int dy[2][4] = {{0, 1, 0, -1}, {0, -1, 0, 1}};
    for (int i = 0; i < k; i++) {
        int x, y, t;
        scanf("%d %d %d", &x, &y, &t);
        x += 50, y += 50;
        int q = 1, r = 0;
        while (q < 101 * 101) {
            for (int j = 0; j < (r+2)/2; j++) {
                if (a[x][y] == 0 || q < a[x][y]) {
                    a[x][y] = q;
                }
                x += dx[t][r%4];
                y += dy[t][r%4];
                q++;
            }
            r++;
        }
    }

    for (int i = 51; i < 51 + n; i++) {
        for (int j = 51; j < 51 + m; j++) {
            printf("%d%c", a[i][j], j == 50 + m ? '\n' : ' ');
        }
    }

    return 0;
}

Compilation message

spirale.cpp: In function 'int main()':
spirale.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
spirale.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &x, &y, &t);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 516 KB Output is correct
8 Correct 2 ms 516 KB Output is correct
9 Correct 42 ms 660 KB Output is correct
10 Correct 2 ms 676 KB Output is correct