답안 #1020023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020023 2024-07-11T12:58:09 Z ajay Spirale (COCI18_spirale) C++17
80 / 80
44 ms 484 KB
/* Ajay Jadhav */
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <string.h>
#include <climits>
#include <cstring>
using namespace std;
 
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        '\n'


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}
};

void solve()
{
	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];
        }
    }     
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 44 ms 484 KB Output is correct
10 Correct 1 ms 348 KB Output is correct