Submission #293484

#TimeUsernameProblemLanguageResultExecution timeMemory
2934847_7_7Spirale (COCI18_spirale)C++17
80 / 80
53 ms384 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e1 + 7; int n; int m; int k; int cnt; int a[N][N]; void upd(int x, int y, int val){ if(1 <= x && x <= n){ if(1 <= y && y <= m){ cnt ++; a[x][y] = min(a[x][y], val); } } } vector<vector<int>> t{ {2, 3, 1, 0}, {3, 2, 0, 1} }; int main() { ios_base::sync_with_stdio(false); cin >> n >> m >> k; memset(a, 64, sizeof a); for(int i = 1; i <= k; i ++){ int x, y, type, dir = 0, val = 1, len = 1; cin >> x >> y >> type; cnt = 0; upd(x, y, val); while(cnt < n * m){ for(int i = 1; i <= len; i ++){ val ++; if(dir == 0) x --; if(dir == 1) x ++; if(dir == 2) y ++; if(dir == 3) y --; upd(x, y, val); } if(dir == 2 || dir == 3) len ++; dir = t[type][dir]; } } for(int i = 1; i <= n; i ++){ for(int j = 1; j <= m; j ++){ cout << a[i][j] << " \n"[j == m]; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...