-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathnoname.cpp
45 lines (37 loc) · 904 Bytes
/
noname.cpp
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
# include <cstdio>
# include <algorithm>
# define NR 1005
using namespace std;
int i,j,n,m,CI,CS,x;
short a[NR][NR], L[NR], C[NR];
int main ()
{
freopen ("noname.in", "r", stdin);
freopen ("noname.out", "w", stdout);
scanf ("%d", &n);
for (i=1; i<=n; ++i) {
scanf ("%d", &x);
L[x]=i;
}
for (i=1; i<=n; ++i) {
scanf ("%d", &x);
C[x]=i;
}
for (i=1; i<=(n+1)/2; ++i) {
CI=i; CS=n-i+1;
//mai intai CS
for (j=1; j<=n; ++j) {
if (a[L[CS]][j]==0) a[L[CS]][j]=2;
if (a[j][C[CS]]==0) a[j][C[CS]]=2;
if (a[L[CI]][j]==0 && j!=C[CS]) a[L[CI]][j]=1;
if (a[j][C[CI]]==0 && j!=L[CS]) a[j][C[CI]]=1;
}
}
printf ("1\n");
for (i=1; i<=n; ++i) {
for (j=1; j<=n; ++j)
printf ("%d ", a[i][j]-1);
printf ("\n");
}
return 0;
}