-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUVa - 11902 - Denominator.cpp
84 lines (70 loc) · 1.42 KB
/
UVa - 11902 - Denominator.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
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
#include<bits/stdc++.h>
using namespace std;
#define take cin >>
#define print cout <<
const int sz = 110;
int arr[sz][sz];
char ans[sz][sz];
int test;
int totalNodes;
int relation;
int i, j, k;
int cnt;
void prLine()
{
print "+";
for(int i=1; i<totalNodes*2; i++)
print "-";
print "+\n";
}
int main()
{
freopen("_in.txt", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0);
take test;
while(test--)
{
take totalNodes;
for(i=1; i<=totalNodes; i++)
{
for(j=0; j<totalNodes; j++)
{
take relation;
arr[i][j] = arr[i-1][j] + relation;
ans[i][j] = 'N';
}
}
for(i=totalNodes, j=1; j<totalNodes; j++)
{
if(arr[i][j]==1)
{
for(k=i-1; arr[k][j]!=0; k--);
ans[k][j] = 'Y';
}
ans[j][j] = 'Y';
}
// output
print "Case ";
print ++cnt;
print ":\n";
prLine();
print "|";
for(i=0; i<totalNodes; i++)
print "Y|";
print "\n";
prLine();
for(i=1; i<totalNodes; i++)
{
print "|";
for(j=0; j<totalNodes; j++)
{
print ans[i][j];
print "|";
}
print "\n";
prLine();
}
}
return 0;
}