답안 #1018496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018496 2024-07-10T06:19:37 Z vjudge1 Spirale (COCI18_spirale) C++17
32 / 80
33 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 55;
int n, m, k, ans[N][N], mat[N][N];

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
// U R D L

vector<int> vec;

bool valid(int x, int y){
    return (x > 0 and y > 0 and x <= n and y <= m);
}

void work(int x, int y, int t){
    int cur = 1;
    for (int i = 0; i < vec.size(); i ++){
        int d = i % 4;
        for (int j = 0; j < vec[i]; j ++){
            x += dx[d];
            y += dy[d];
            cur++;

            if (valid(x, y)){
                mat[x][y] = cur;
                ans[x][y] = min(ans[x][y], mat[x][y]);
            }
        }
    }
}


int main(){
    memset(ans, 31, sizeof ans);
    for (int i = 1; i <= 100; i ++)
        vec.push_back(i), vec.push_back(i);

    cin >> n >> m >> k;
    for (int i = 0; i < k; i ++){
        int x, y, t;
        cin >> x >> y >> t;

        memset(mat, 31, sizeof mat);

        ans[x][y] = mat[x][y] = 1;
        work(x, y, t);
    }

    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= m; j ++)
            cout << ans[i][j] << " ";
        cout << endl;
    }
}

Compilation message

spirale.cpp: In function 'void work(int, int, int)':
spirale.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < vec.size(); i ++){
      |                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Correct 33 ms 348 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct