The Government of "Moderdesh" is planning to enter the digital age and so people of different profession
And business is proposing different ways to enter this age successfully. The hardware vendors is
Saying that we need to provide a laptop for each student, the mobile companies is saying that every
Children needs to has a mobile phone in he small hand and talk all night long, the multimedia experts
Is crying for multimedia University and so on. But very few is crying for the overall improvement
of computer science education. We do not understand is being only the consumer of modern
Digital Technologies We cannot enter the real digital age.
Now as a protest, some local computer geeks is planning to digitize the local vegetable and grocery
In a strange. The local generally use weighing balances as shown in the Figure-1
And they use conventional weight sets as shown in Figure 2. The computer geeks want to introduce a
New type of weight set, where each piece would have the shape of a upper case 中文版 alphabet, and
Strangely figure 1:the weighing balance weighing a figure 2:the weights of these pieces would papaya
Using letter shaped weights. Conventional weight set is related with their ASCII valuess. For example
The ASCII value of ' A ' is which, which is 10000012 in binary. For each ' 1 ' in binary representation a weight
Of the GMS would be added and for each ' 0 ' in binary representation a weight of the GMs would be added.
So a piece with shape ' a ' actually weighs (5 + 2) GM = 2250 grams. Note that leading
Zeroes in binary representation is not considered. The geeks believe if others is correct about their
Ways to enter digital age, they is also correct about digitizing the local in the introducing new
Weight sets related to ASCII characters.
Now on this problem you'll be given (i) the picture of a weighing scale and the weight pieces that
It contains in left pan and in the right pan (ii) you'll also be informed which pan is heavier and
Which pan is lighter (not necessarily correct). You'll have to detect whether the given information
is correct or not. If The given information is isn't correct you'll have to rectify the picture and show
It in the output.
Input
First line of the input file contains a positive integer T (t≤6000) that denotes the number of test
Sets. The description of each set of input is given below:
Each set of input are given in a (7) grid. This grid actually contains the plain text description
of a weighing scale. Each location of the grid is either a dot '. ' (ASCII value) or a front slash '/'
(ASCII value) or a back slash ' \ ' (ASCII value of the under) or an score ' _ ' (ASCII value-a) or a pipe
| (ASCII value 124) An upper case 中文版 Alphabet (ASCII value of 90). The (7) grid is
Divided into and equal parts by the vertical lines formed with pipe character. The left part denotes the
The status of left pan and right part denotes the status of the right pan. The bottom of the pan is formed
With 6 (six) under score characters and the ropes attached to the pans is formed with front slash and
Back slash. The weights on both pans is placed just above the row that denotes bottom of the pan
And they is left justified. There can maximum 6 weights on a single pan. There is three possible
Vertical positioning of the pans (i) left pan was low and right Pan was high (ii) Both Pan was in the middle
(iii) left pan was high and right pan are low. If weight of both pan is same then they should being in state
(ii), if the left pan was heavier then they should are in status (i) and so on. In the input the pans is
Always in position (i), (ii) or (iii) and that is not being the correct position according to the weights
They contain.
A line containing (eighteen) '-' (minus) signs follows each set of input.
Output
For each set of input produce, or eight line of output. First line should contain the serial of output.
If the pans in the input figure is in correct position according to the weights they contain then in
The second line print "the correct." (without the quotes). If the pans is not in correct
Position then print the weighing balance again in a (7) grid with the pans in the correct position.
Look at the output for sample input for exact formatting.
Sample Input
4
........|| .../\...
........||.. /.. \..
.../\...||. /....\.
.. /.. \..|| /g.....\
./....\.|| \______/
/yqyfu.\| | ........
\______/|| ........
------------------
.../\...|| ........
.. /.. \..|| ........
./....\.|| .../\...
/wcgqg.\| |. /.. \..
\______/||. /....\.
........|| /oya...\
........|| \______/
------------------
.../\...|| ........
.. /.. \..|| ........
./....\.|| .../\...
/a.....\| |. /.. \..
\______/||. /....\.
........|| /a.....\
........|| \______/
------------------
........|| ........
.../\...|| .../\...
.. /.. \..||.. /.. \..
./....\.||. /....\.
/nq....\| | /fg....\
\______/|| \______/
........|| ........
------------------
Sample Output
Case 1:
The figure is correct.
Case 2:
........|| .../\...
........||.. /.. \..
.../\...||. /....\.
.. /.. \..|| /oya...\
./....\.|| \______/
/wcgqg.\| | ........
\______/|| ........
Case 3:
........|| ........
.../\...|| .../\...
.. /.. \..||.. /.. \..
./....\.||. /....\.
/a.....\| | /a.....\
\______/|| \______/
........|| ........
Case 4:
The figure is correct
Test instructions: Enter a balance to the ASCII value of the binary, 0 means 250,1 500, ask the balance of the two ends of the position is correct,
If the correct output is correct. Incorrect, the correct balance position map is output.
This simulation, a bit of trouble.
#include <stdio.h> #include <string.h>char mp[10][20];char s1[8],s2[8];int vale[30] = { 2250,2250,2500,2250,2500,2500,2750,2250,2500,2500,2750,2500,2750,2750,3000,2250,2500,2500,2750,2500,2750,2750,3000,2500,2 750,2750,};int Main () {int t,a1,a2,sum1,sum2,cas=1;scanf ("%d", &t), while (t--) {char str1[8][20]={"... | | ........",".../\\...|| .../\\...",".. /.. \\..||.. /.. \\..","./....\\.||. /....\\.","/......\\|| /......\\","\\______/|| \\______/","........|| ........" } ; char str2[8][20]={"... | | .../\\...","........||.. /.. \\..",".../\\...||. /....\\.",".. /.. \\..|| /......\\","./....\\.|| \\______/","/......\\|| ........","\\______/|| .......};char str3[8][20]={.../\\...| | ........",".. /.. \\..|| ........","./....\\.|| .../\\...","/......\\||.. /.. \\..","\\______/||. /....\\.","........|| /......\\","........|| \\______/"};int k1=0,k2=0,i,j;sum1=sum2=0;a1=a2=-1;memset (S1, ' + ', sizeof (S1)), memset (S2, ' n ', sizeof (S2)); for (i= 0;i<8;++i) {scanf ("%s", Mp[i]), for (J=0;J<18;++J) {if (mp[i][j]== '/' && j<8) {if (a1==-1) A1=I;//A1 record the highest number of rows on the left (}if '/' && mp[i][j]==) {if (j>9) A2==-1 record to the right of A2=I;//A2 ( Mp[i][j]>= ' A ' && mp[i][j]<= ' Z ' && j<8) {sum1+=vale[mp[i][j]-' a '];s1[k1++]=mp[i][j];} if (mp[i][j]>= ' a ' && mp[i][j]<= ' Z ' && j>9) {sum2+=vale[mp[i][j]-' a '];s2[k2++]=mp[i][j];}} }if (a1==a2 && sum1==sum2)//Correct condition printf ("Case%d:\nthe figure is correct.\n", cas++); else if (A1<a2 && SUM1<SUM2) printf ("Case%d:\nthe figure was correct.\n", cas++), else if (a1>a2 && sum1>sum2) printf ("Case %d:\nthe figure was correct.\n ", cas++); else if (a1>a2 && sum1<sum2) {//Incorrect printf (" Case%d:\n ", cas++); for (I=0,J=1;I<K1;++I,++J) str3[3][j]=s1[i];for (i=0,j=11;i<k2;++i,++j) str3[5][j]=s2[i];for (i=0;i<7;++i) {printf ("%s\n", Str3[i]);}} else if (a1<a2 && sum1>sum2) {printf ("Case%d:\n", cas++); for (I=0,J=1;I<K1;++I,++J) str2[5][j]=s1[i]; for (I=0,J=11;I<K2;++I,++J) str2[3][j]=s2[i];for (i=0;i<7;++i) {printf ("%s\n", Str2[i]);}} else if ((a1>a2 | | a1<a2) && (sum1==sum2)) {printf ("Case%d:\n", cas++); for (I=0,J=1;I<K1;++I,++J) str1[ 4][j]=s1[i];for (i=0,j=11;i<k2;++i,++j) str1[4][j]=s2[i];for (i=0;i<7;++i) {printf ("%s\n", Str1[i]);}} else if (a1==a2 && sum1<sum2) {printf ("Case%d:\n", cas++); for (I=0,J=1;I<K1;++I,++J) str3[3][j]=s1[i]; for (I=0,J=11;I<K2;++I,++J) str3[5][j]=s2[i];for (i=0;i<7;++i) printf ("%s\n", Str3[i]);} else if (a1==a2 && sum1>sum2) {printf ("Case%d:\n", cas++); for (I=0,J=1;I<K1;++I,++J) str2[5][j]=s1[i]; for (I=0,J=11;I<K2;++I,++J) str2[3][j]=s2[i];for (i=0;i<7;++i) printf ("%s\n", Str2[i]);}} return 0;}
UVA 4854 A Digital satire of digital age (analog)