File tree 6 files changed +49
-0
lines changed
6 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ 2
2
+ 2 3
3
+ 3 3 1
Original file line number Diff line number Diff line change
1
+ 3
2
+ 2 3 1
Original file line number Diff line number Diff line change
1
+ 1
2
+ 2 2
3
+ 3 3 3
4
+ 4 4 4 4
5
+ 5 5 5 5 5
Original file line number Diff line number Diff line change
1
+ 5
2
+ 1 2 3 4 5
Original file line number Diff line number Diff line change
1
+ // https://codeforces.com/contest/1517/problem/C
2
+ #include < bits/stdc++.h>
3
+
4
+ using namespace std ;
5
+ const int N = 505 ;
6
+ int xs[N][N];
7
+
8
+ int main () {
9
+ cin.tie (0 ), ios::sync_with_stdio (0 );
10
+ int n;
11
+ cin >> n;
12
+ for (int i = 0 ; i < n; i++) cin >> xs[i][i];
13
+ for (int ii = 0 ; ii < n; ii++) {
14
+ int k = xs[ii][ii];
15
+ int dy[4 ] = {0 , 1 , 0 , -1 };
16
+ int dx[4 ] = {-1 , 0 , 1 , 0 };
17
+ int y = ii, x = ii;
18
+ for (int j = 1 ; j < k; j++)
19
+ for (int i = 0 ; i < 4 ; i++) {
20
+ int yy = y + dy[i], xx = x + dx[i];
21
+ if (yy >= 0 && yy < n && xx >= 0 && xx < n && !xs[yy][xx]) {
22
+ xs[yy][xx] = k;
23
+ y = yy, x = xx;
24
+ break ;
25
+ }
26
+ }
27
+ }
28
+ for (int i = 0 ; i < n; i++)
29
+ for (int j = 0 ; j <= i; j++)
30
+ if (!xs[i][j]) {
31
+ cout << " -1\n " ;
32
+ return 0 ;
33
+ }
34
+ for (int i = 0 ; i < n; i++)
35
+ for (int j = 0 ; j <= i; j++) cout << xs[i][j] << " \n " [j == i];
36
+ }
Original file line number Diff line number Diff line change 3
3
There are solutions for the following [ codeforces] ( http://codeforces.com/ ) problems:
4
4
5
5
### Contests ([ problemset site] ( https://codeforces.com/problemset ) )
6
+ 1 . [ 1517C - Fillomino 2] ( 1517/c.cc ) ([ problem site] ( https://codeforces.com/contest/1517/problem/C ) )
6
7
1 . [ 1517B - Morning Jogging] ( 1517/b.cc ) ([ problem site] ( https://codeforces.com/contest/1517/problem/B ) )
7
8
1 . [ 1517A - Sum of 2050] ( 1517/a.cc ) ([ problem site] ( https://codeforces.com/contest/1517/problem/A ) )
8
9
1 . [ 1500B - Two chandeliers] ( 1501/d.cc ) ([ problem site] ( https://codeforces.com/contest/1500/problem/B ) )
You can’t perform that action at this time.
0 commit comments