#include <iostream>
#include <iomanip>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
#define dbg(x) cerr<<#x<<": "<<x<<"\n";
/*
I love Valentina Notta uwuwuwu
*/
int curr;
vector<vector<int>>ans(50+1, vector<int>(50+1, 1e9));
void nottauwu(int x, int y, int xx, int yy, int aux, int n, int m){
for(int i=0 ; i<aux ; i++){
// dbg(x)
// dbg(y)
// dbg(curr)
++curr;
if(x>=1 && y>=1 && x<=n && y<=m){
ans[x][y]=min(ans[x][y], curr);
}
x+=xx;
y+=yy;
}
}
void solve(){
int n, m, k; cin>>n>>m>>k;
for(int valenottauwu=0 ; valenottauwu<k ; valenottauwu++){
int x, y, t; cin>>x>>y>>t;
if(t==1){
curr=1;
ans[x][y]=1;
for(int i=1 ; i<max(n, m) ; i++){
nottauwu(x-i, y+i-1, 0, -1, i*2, n, m);
nottauwu(x-i+1, y-i, 1, 0, i*2, n, m);
nottauwu(x+i, y-i+1, 0, 1, i*2, n, m);
nottauwu(x+i-1, y+i, -1, 0, i*2, n, m);
}
}else{
curr=1;
ans[x][y]=1;
for(int i=1 ; i<max(n, m) ; i++){
nottauwu(x-i, y-i+1, 0, 1, i*2, n, m);
nottauwu(x-i+1, y+i, 1, 0, i*2, n, m);
nottauwu(x+i, y+i-1, 0, -1, i*2, n, m);
nottauwu(x+i-1, y-i, -1, 0, i*2, n, m);
}
}
}
for(int i=1 ; i<=n ; i++){
for(int j=1 ; j<=m ; j++) cout<<ans[i][j]<<" ";
cout<<"\n";
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |