# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
293484 | 7_7_7 | Spirale (COCI18_spirale) | C++17 | 53 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |