Submission #1020023

#TimeUsernameProblemLanguageResultExecution timeMemory
1020023ajaySpirale (COCI18_spirale)C++17
80 / 80
44 ms484 KiB
/* 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...