-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspiralMatrixPrint.cpp
More file actions
49 lines (41 loc) · 889 Bytes
/
Copy pathspiralMatrixPrint.cpp
File metadata and controls
49 lines (41 loc) · 889 Bytes
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
// INCOMPLETE
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
const int mod = 1e9+7;
void solve(){
int n;
cin >> n;
vector<vector<int>> grid(n, vector<int> (n, 0)>);
int l=n-1; int k=0;
int cnt=1;
int alt=1;
for(int i=k; i<=l; i++){
if(alt == 1){
grid[k][i] = cnt++;
alt *= -1;
}
else{
grid[i][k] = cnt++;
alt *= -1;
}
if(i == l){
if(alt == -1){
i = k+1;
k =
}
}
}
}
int main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t = 1;
// cin >> t;
while(t--)
solve();
}