-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.cpp
More file actions
30 lines (28 loc) · 686 Bytes
/
file.cpp
File metadata and controls
30 lines (28 loc) · 686 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
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<vector<int>> a(n, vector<int>(n));
for(int row = 0; row < n; row++){
for(int col = 0; col < n; col++){
set<int> s;
for(int r = 0; r < row; r++){
s.insert(a[r][col]);
}
for (int c = 0; c < col; c++){
s.insert(a[row][c]);
}
int x= 0;
while(s.count(x) != 0){
x++;
}
a[row][col] = x;
cout << x << " ";
}
cout << "\n";
}
return 0;
}