-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUVa - 12280 - A Stair of Digital Age.cpp
144 lines (132 loc) · 2.46 KB
/
UVa - 12280 - A Stair of Digital Age.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include<bits/stdc++.h>
using namespace std;
const int grlen = 18;
const int grheight = 7;
const int lpart = 8;
const int rpart = 9;
string dummystring;
char dummychar;
char grid[grheight][grlen];
int t, tcase;
int lpos, rpos;
int lweight, rweight;
int weightOf(char c)
{
int num = (int) c;
int weight = 0;
while(num>0)
{
if((num&1)==1)
{
weight += 500;
}
else
{
weight += 250;
}
num = num >> 1;
}
return weight;
}
int getweight(int start)
{
int lim = start+lpart;
int weight = 0;
for(int i=0; i<grheight; i++)
{
for(int j=start; j<lim; j++)
{
dummychar = grid[i][j];
if(dummychar>='A' && dummychar<='Z')
{
weight += weightOf(dummychar);
}
}
}
return weight;
}
int getposleft()
{
int i=4, j=3;
if(grid[i][j]=='_')
return i;
i++;
if(grid[i][j]=='_')
return i;
return ++i;
}
int getposright()
{
int i=4, j=13;
if(grid[i][j]=='_')
return i;
i++;
if(grid[i][j]=='_')
return i;
return ++i;
}
bool isokay()
{
if(lweight>rweight && lpos>rpos)
{
return true;
}
if(lweight==rweight && lpos==rpos)
{
return true;
}
if(lweight<rweight && lpos<rpos)
{
return true;
}
return false;
}
void rectifyfigure()
{
return;
}
int main()
{
freopen("_in.txt", "r", stdin);
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> t;
cout << t << endl;
while(t--)
{
for(int i=0; i<grheight; i++)
{
for(int j=0; j<grlen; j++)
{
cin >> grid[i][j];
}
}
cin >> dummystring;
// input is okay
lweight = getweight(0);
rweight = getweight(rpart+1);
//cout << "GOT WEIGHT";
lpos = getposleft();
rpos = getposright();
cout << "Case " << ++tcase << ":\n";
if(isokay())
{
cout << "The figure is correct.";
//code is okay till here
}
else
{
rectifyfigure();
for(int i=0; i<grheight; i++)
{
for(int j=0; j<grlen; j++)
{
cout << grid[i][j];
}
cout << "\n";
}
}
cout << "\n";
}
return 0;
}