제출 #1018494

#제출 시각아이디문제언어결과실행 시간메모리
1018494vjudge1Spirale (COCI18_spirale)C++17
32 / 80
11 ms348 KiB
#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 <= 50; 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;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

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 ++){
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...