-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10836.cpp
More file actions
91 lines (82 loc) · 1.48 KB
/
10836.cpp
File metadata and controls
91 lines (82 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int arr[701][701];
vector<int> v[1000001];
int dy[3] = {0,-1,-1};
int dx[3] = {-1,-1,0};
int n,m;
void solve(int idx)
{
int temp = v[idx][0];
int y;
int x;
if(temp<m-1)
{
y = m-1-temp;
x = 0;
}
else
{
y = 0;
x = temp -(m-1);
}
for (int i = 1; i < 3; i++)
{
for(int j = 0; j < v[idx][i]; j++)
{
arr[y][x] = arr[y][x] + i;
if(y>0) y--;
else x++;
}
}
}
int main(int argc, char** argv)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int a;
cin>>m>>n;
for(int i = 0; i< m; i++)
{
for(int j = 0; j < m; j++)
{
arr[i][j] = 1;
}
}
for (int i = 0; i < n; i++)
{
for(int j = 0; j < 3;j++)
{
cin>>a;
v[i].push_back(a);
}
}
for (int i = 0; i < n; i++)
{
solve(i);
}
for(int i = 1; i < m; i++)
{
for(int j = 1; j<m; j++)
{
int mx = 0;
for(int k = 0; k < 3; k++)
{
if(mx<arr[i+dy[k]][j+dx[k]]) mx = arr[i+dy[k]][j+dx[k]];
}
arr[i][j] = mx;
}
}
for(int i = 0; i < m; i++)
{
for(int j = 0; j < m; j++)
{
cout<<arr[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}