| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1018494 | vjudge1 | Spirale (COCI18_spirale) | C++17 | 11 ms | 348 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
    }
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
