## 500 - Table

All about problems in Volume 5. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

medv
Learning poster
Posts: 85
Joined: Sun Jul 14, 2002 1:17 pm

### 500 - Table

Can smb help me? Why WA?

program p500;
const
MAX = 255;
Rows = 100;
var
TempString,s:string;
x,AmountIndex,Row,Column,Counter,i,j,k:integer;
Amount,MaxLength:array[1..MAX] of integer;
Table:array[1..Rows,1..MAX] of string;

function GetRealString(s:String):string;
var
i,j:integer;
begin
i := 1; j := length(s);
while ((i <= j) and (s[i] = ' ')) do Inc(i);
while ((j >= i) and (s[j] = ' ')) do Dec(j);
GetRealString := copy(s,i,j-i+1);
end;

procedure DrawLine (NumberOfColumns: integer; Left, Middle, Right: char);
var i, k: integer;
begin
write (Left);
for i := 1 to NumberOfColumns do
begin
for k := 1 to MaxLength[i] do write ('?');
if i = NumberOfColumns then writeln(Right) else write(Middle);
end;
end;

begin
FillChar(MaxLength,sizeof(MaxLength),0);
FillChar(Amount,sizeof(Amount),0);
Row := 1; AmountIndex := 1;
readln(s); {Read First Header Line}
while True do
begin
readln(s);
s := GetRealString(s);
if s[1] = '?' then break;
if s[1] = '?' then
begin
Inc(AmountIndex);
continue;
end;
Inc(Amount[AmountIndex]);
{now s[1] = '?'}
delete(s,1,1); {Delete first character '?'}
i := pos('?',s); Counter := 1;
while (i > 0) do
begin
TempString := copy(s,1,i-1);
TempString := GetRealString(TempString);
if length(TempString) + 2 > MaxLength[Counter]
then MaxLength[Counter] := length(TempString) + 2;
Table[Row,Counter] := TempString;
delete(s,1,i);
i := pos('?',s); Inc(Counter);
end;
Inc(Row);
end;
Column := Counter - 1; x:=1;
DrawLine (Column, '?', '?', '?'); {High Line}
for i:=1 to Row-1 do
begin
for j:=1 to Column do
begin
write('? '); write(Table[i,j]);
for k:=length(Table[i,j])+2 to MaxLength[j] do write(' ');
end;
writeln('? ');
Dec(Amount[x]);
if Amount[x] = 0 then
begin
if i < Row-1 then DrawLine (Column, '?', '?', '?'); {Middle Line}
Inc(x);
end;
end;
DrawLine (Column, '?', '?', '?'); {Bottom Line}
end.

MW
New poster
Posts: 3
Joined: Sun Sep 26, 2004 2:09 pm

### 500: Table

My program currently segfaults when I submit it, even though it passes anything I try it on locally. Does anyone have test files they could post here? Thanks.

stubbscroll
Experienced poster
Posts: 151
Joined: Tue Nov 16, 2004 7:23 pm
Location: Norway
Contact:
Does your program handle multiple input? (You did notice the blue icon by the problem number?)

The input format ls like this:

N (number of cases)
\n (blank line)
table 1
\n (blank line)
table 2
...
table N

If you already handle this, try to increase your array sizes...

rcs
New poster
Posts: 3
Joined: Sun Dec 02, 2012 6:47 pm

### Re: 500 - Table

I've tried to handle multiple test case but I still get WA. Any tricky inputs?
My code

Code: Select all

``````AC
``````
Last edited by rcs on Sun Dec 09, 2012 10:32 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 500 - Table

an uuencoded input and output

Code: Select all

``````begin 644 500.in
M,0H*VL3\$Q,3\$Q,+\$Q,3\$Q+\-"K-A86\$@(+,@(" @(" @(" @("!B8F(@(&-C
M8R @LPT*P\3\$Q,3\$Q,7\$Q,3\$Q+0-"K,@(#\$R,R"S(" @(&\$_(2 @LPT*L[,R
;,C(R,C(R,C(R,K,-"L#\$Q,3\$Q,3!Q,3\$Q,39

end``````

Code: Select all

``````begin 644 500.out
MVL3\$Q,3\$PL3\$Q,3\$Q,3\$Q,3\$Q,2_"K,@86%A(+,@8F)B("!C8V,@(" @LPK#
MQ,3\$Q,3%Q,3\$Q,3\$Q,3\$Q,3\$Q+0*LR Q,C,@LR!A/R\$@(" @(" @(""S"K,@
J(" @(+,@,C(R,C(R,C(R,C(@LPK Q,3\$Q,3!Q,3\$Q,3\$Q,3\$Q,3\$Q-D*

end``````
Check input and AC output for thousands of problems on uDebug!

rcs
New poster
Posts: 3
Joined: Sun Dec 02, 2012 6:47 pm

### Re: 500 - Table

brianfry713 wrote:an uuencoded input and output

Code: Select all

``````begin 644 500.in
M,0H*VL3\$Q,3\$Q,+\$Q,3\$Q+\-"K-A86\$@(+,@(" @(" @(" @("!B8F(@(&-C
M8R @LPT*P\3\$Q,3\$Q,7\$Q,3\$Q+0-"K,@(#\$R,R"S(" @(&\$_(2 @LPT*L[,R
;,C(R,C(R,C(R,K,-"L#\$Q,3\$Q,3!Q,3\$Q,39

end``````

Code: Select all

``````begin 644 500.out
MVL3\$Q,3\$PL3\$Q,3\$Q,3\$Q,3\$Q,2_"K,@86%A(+,@8F)B("!C8V,@(" @LPK#
MQ,3\$Q,3%Q,3\$Q,3\$Q,3\$Q,3\$Q+0*LR Q,C,@LR!A/R\$@(" @(" @(""S"K,@
J(" @(+,@,C(R,C(R,C(R,C(@LPK Q,3\$Q,3!Q,3\$Q,3\$Q,3\$Q,3\$Q-D*

end``````
Hi brian, thanks for your response. But I still don't quite understand about the sample I/O you give.
How do I test my program using your file?
And about the judge's program, how does it compare my output with their own output?

rcs
New poster
Posts: 3
Joined: Sun Dec 02, 2012 6:47 pm

### Re: 500 - Table

Ignore my previous post. It seems that my input reading does not work well. AC already. Thanks

dull_jester
New poster
Posts: 17
Joined: Fri Oct 21, 2016 12:58 pm
Location: NS, Canada

### Re: 500 - Table

I have the following Java code which gives WA:

Code: Select all

``````/*
* 500. Table
* TOPIC: ad hoc, formatting
* status: in progress
*/
import java.util.*;
import java.util.regex.*;
import java.io.*;

class Main {
final static int N = 0x800;
Pattern rawElem = Pattern.compile("\\u2502[^\\u2502]*",Pattern.UNICODE_CHARACTER_CLASS);
Pattern elem = Pattern.compile("[^\\u2502\\s].*\\S",Pattern.UNICODE_CHARACTER_CLASS);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int m,n,curMark;
int []rowLabel,columnWidth;
List<String> rows;
Map<Integer,List<String>> q;

static int []cp = {0x2502,0x2524,0x2510,0x2514,0x2534,0x252C,0x251C,0x2500,0x253C,0x2518,0x250C};
static Set<Character> specials;
static {
specials = new HashSet<>();
for ( int x: cp )
specials.add((char)x);
}

public static void main( String ... args ) throws Exception {
new Main().go();
}

boolean isEmpty( String s ) {
for ( char c: s.toCharArray() )
if ( c != ' ' && c != '\t' && c != '\n' && c != '\r' )
return false ;
return true ;
}

boolean isHRule( String s ) {
for ( char c: s.toCharArray() )
if ( specials.contains(c) && c != (char)cp[0] )
return true ;
return false ;
}

String createUpper() {
StringBuilder sb = new StringBuilder();
sb.append((char)cp[10]);
for ( int j = 0; j < n; ++j ) {
for ( int k = 0; k < columnWidth[j]; ++k )
sb.append((char)cp[7]);
sb.append(j==n-1?(char)cp[2]:(char)cp[5]);
}
return sb.toString();
}
String createLower() {
StringBuilder sb = new StringBuilder();
sb.append((char)cp[3]);
for ( int j = 0; j < n; ++j ) {
for ( int k = 0; k < columnWidth[j]; ++k )
sb.append((char)cp[7]);
sb.append(j==n-1?(char)cp[9]:(char)cp[4]);
}
return sb.toString();
}
String createMid() {
StringBuilder sb = new StringBuilder();
sb.append((char)cp[6]);
for ( int j = 0; j < n; ++j ) {
for ( int k = 0; k < columnWidth[j]; ++k )
sb.append((char)cp[7]);
sb.append(j==n-1?(char)cp[1]:(char)cp[8]);
}
return sb.toString();
}

boolean emptyRow( int i ) {
for ( String t : q.get(i) )
for ( char ch: t.toCharArray() )
if ( ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' )
return false ;
return true ;
}

void go() throws Exception {
int i,j,k,ts,total,prevGroup;
String s;
boolean []isEmptyGroup;

for ( ts = Integer.parseInt(br.readLine()), br.readLine(); ts-->0; ) {
rowLabel = new int[N];
columnWidth = new int[N];
for ( m = 0, curMark = 0, rows = new ArrayList<>(); (s = br.readLine()) != null && !isEmpty(s); ) {
if ( isHRule(s) ) {
++curMark;
continue ;
}
rowLabel[m++] = curMark;
rows.add(s);
for ( char t: s.toCharArray() )
if ( specials.contains(t) && t != (char)cp[0] ) {
int ass = 1/0;
}
}
q = new TreeMap<>();
for ( i = 0; i < m; ++i ) {
q.put(i,new ArrayList<String>());
for ( Matcher rm = rawElem.matcher(rows.get(i)); rm.find(); ) {
Matcher mt = elem.matcher(rm.group(0));
if ( mt.find() )
q.get(i).add(" "+mt.group(0)+" ");
else q.get(i).add("");
}
}
for ( total = 0, n = q.get(m-1).size()-1, j = 0; j < n; total += columnWidth[j++] )
for ( i = 0; i < m; ++i )
columnWidth[j] = Math.max(q.get(i).get(j).length(),columnWidth[j]);

isEmptyGroup = new boolean[curMark];
for ( i = 0; i < curMark; isEmptyGroup[i++] = true );
for ( i = 0; i < m; ++i )
if ( !emptyRow(i) )
isEmptyGroup[rowLabel[i]] = false ;

String up = createUpper(), down = createLower(), mid = createMid();

System.out.println(up); prevGroup = -1;
for ( i = 0; i < m; ++i ) {
if ( emptyRow(i) ) continue ;
if ( prevGroup != -1 && prevGroup != rowLabel[i] )
System.out.println(mid);
for ( j = 0; j < n; ++j ) {
System.out.print((char)cp[0]);
System.out.print(q.get(i).get(j));
for ( k = q.get(i).get(j).length()+1; k <= columnWidth[j]; ++k )
System.out.print(' ');
prevGroup = rowLabel[i];
}
System.out.println((char)cp[0]);
}
System.out.println(down);
if ( ts > 0 ) System.out.println();
// System.out.println();
}
}
}

``````
I passes Brian's input. But WA at UVa. What are we to do with empty rows? Completely delete them or print them as they are? The description says there are no empty columns, but then -- there may be empty rows.

feodorv
New poster
Posts: 5
Joined: Mon Jun 06, 2016 12:42 pm

### Re: 500 - Table

An uuencoded input and output

Code: Select all

``````begin 600 si
M,@T*#0K:Q,3\$Q,3\$Q,+\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$PL3\$Q,3\$Q,3\$
MQ,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$OPT*LR!.86UE("`@("`@
M("`@LR!/<F=A;FEZ871I;VX@("`@LR!*3T(@("`@(""S#0K#Q,3\$Q,3\$Q,7\$
MQ,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q<3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$Q,3\$Q,3\$Q<3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3%
MQ,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,2T#0JS(\$)I
M;&P@4&]U8VAE<B`@LR`@("`@02`@0R`@32`@(+,@("`@("`@("`@(\$EN=&5R
M;F%T:6]N86P@0V]L;&5G:6%T92!0<F]G<F%M;6EN9R"S#0JS("`@("`@("`@
M("`@("`@(+,@("`@("`@("`@("`@(+,@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@LPT*LR`@("`@("`@("`@("`@(""S("`@
M("`@("`@("`@(""S("`@("`@0V]N=&5S="!\$:7)E8W1O<B`@("`@("`@("`@
M("`@("`@("`@(+,-"L/\$Q,3\$Q,3\$Q<3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3%
MQ,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,2T#0JS("`@
M("`@("`@("`@("`@(+,@("`@("`@("`@("`@(+,@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@LPT*LR`@("`@("`@("`@("`@
M(""S(&)B("`@("`@("`@("`@(+,@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@LPT*LR`@("`@("`@("`@("`@(""S("`@("`@
M("`@("`@(""S("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@(+,-"K,@("`@("`@("`@("`@("`@LR`@("`@("`@("`@("`@LR!A
M82`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(+,-
M"K,@("`@("`@("`@("`@("`@LR`@("`@("`@("`@("`@LR`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(""S#0K#Q,3\$Q,3\$Q,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("`@(""S("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@(""S#0JS("`@("`@("`@("`@(""S("`@("`@("`@("`@("`@("`@
M("`@(""S("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(""S
M#0JS(\$)I;&P@4&]U8VAE<B"S(\$\$@(\$,@(\$T@("`@("`@("`@("`@(""S(\$EN
M=&5R;F%T:6]N86P@0V]L;&5G:6%T92!0<F]G<F%M;6EN9R"S#0JS("`@("`@
M("`@("`@(""S("`@("`@("`@("`@("`@("`@("`@(""S("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@(""S#0JS("`@("`@("`@("`@(""S
M("`@("`@("`@("`@("`@("`@("`@(""S("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@(""S#0JS("`@("`@("`@("`@(""S("`@("`@("`@
M("`@("`@("`@("`@(""S(\$-O;G1E<W0@1&ER96-T;W(@("`@("`@("`@("`@
M("`@("`@(""S#0JS("`@("`@("`@("`@(""S("`@("`@("`@("`@("`@("`@
M("`@(""S("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(""S
M#0JS("`@("`@("`@("`@(""S("`@("`@("`@("`@("`@("`@("`@(""S("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(""S#0K#Q,3\$Q,3\$
MQ,3\$Q,3\$Q,3%Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3%Q,3\$Q,3\$Q,3\$Q,3\$
MQ,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,2T#0K#Q,3\$Q,3\$Q,3\$Q,3\$Q,3%
MQ,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3%Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$
MQ,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,2T#0K#Q,3\$Q,3\$Q,3\$Q,3\$Q,3%Q,3\$Q,3\$Q,3\$
MQ,3\$Q,3\$Q,3\$Q,3\$Q,3%Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$
MQ,3\$Q,3\$Q,2T#0K`Q,3\$Q,3\$Q,3\$Q,3\$Q,3!Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$
MQ,3\$Q,3!Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,3\$Q,39
"#0K\$
`
end
``````
I see no special meaning for problem's statement "The output should not contain empty lines".

metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

### Re: 500 - Table

Thank you for your reply! But how can I translate the uuencoded input to C++ style?

metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

### Re: 500 - Table

Still WA, I don't know why. There is my code:

Code: Select all

``````Deleted after ACed.
``````
Last edited by metaphysis on Mon Apr 17, 2017 3:59 am, edited 5 times in total.

metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

### Re: 500 - Table

The test data generator:

Code: Select all

``````#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

const char separator = (char)(179), right_line_separator = (char)(180),
top_right_corner = (char)(191), bottom_left_corner = (char)(192),
bottom_line_separator = (char)(193), top_line_separator = (char)(194),
left_line_separator = (char)(195), link = (char)(196),
middle_line_separator = (char)(197), bottom_right_corner = (char)(217),
top_left_corner = (char)(218);

int main(int argc, char *argv[])
{
srand(time(NULL));

// number of datasets
int cases = rand() % 10 + 1;
cout << cases << '\n';

// generate every dataset
for (int c = 1; c <= cases; c++)
{
cout << '\n';

// lines and columns of table
int lines = rand() % 98 + 3;
int columns = rand() % 10 + 1;

int length_of_cell[columns];
for (int i = 0; i < columns; i++)
length_of_cell[i] = rand() % 10 + 6;

cout << top_left_corner;
for (int i = 0; i < columns - 1; i++)
{
for (int j = 0; j < length_of_cell[i] + 2; j++)
cout << link;
cout << top_line_separator;
}
for (int j = 0; j < length_of_cell[columns - 1]; j++)
cout << link;
cout << top_right_corner << '\n';

string content = "ABCDEFG HIJKLMN OPQRST UVWXYZ";
for (int i = 1; i <= lines / 2; i++)
{
if (i > 1)
{
cout << left_line_separator;
for (int j = 0; j < columns - 1; j++)
{
for (int k = 0; k < length_of_cell[j] + 1; k++)
cout << link;
cout << middle_line_separator;
}
for (int k = 0; k < length_of_cell[columns - 1]; k++)
cout << link;
cout << right_line_separator << '\n';
}

cout << separator;
for (int j = 0; j < columns; j++)
{
if (j > 0)
cout << separator;
cout << ' ' << content.substr(rand() % 26, 10) << ' ';
}
cout << separator << '\n';

// empty line.
if (rand() % 10 > 5)
{
bool drawGap = (rand() % 2) > 0;
cout << separator;
for (int j = 0; j < columns; j++)
{
if (j > 0)
cout << separator;
if (drawGap) cout << ' ' << string(rand() % 30, ' ') << ' ';
}
cout << separator << '\n';
}
}

cout << bottom_left_corner;
for (int i = 0; i < columns - 1; i++)
{
for (int j = 0; j < length_of_cell[i] + 1; j++)
cout << link;
cout << bottom_line_separator;
}
for (int j = 0; j < length_of_cell[columns - 1]; j++)
cout << link;
cout << bottom_right_corner << '\n';
}

return 0;
}
``````
Last edited by metaphysis on Fri Apr 21, 2017 4:05 am, edited 1 time in total.

feodorv
New poster
Posts: 5
Joined: Mon Jun 06, 2016 12:42 pm

### Re: 500 - Table

As far as i can see the input line

Code: Select all

``| |||``
gives invalid output line. The line

Code: Select all

``| || |``
is ok.

Moreover if the line

Code: Select all

``| |||``
is last in the table (among all lines beginning with separator) then the column number is invalid...

metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

### Re: 500 - Table

OK, ACed!
There is no need to remove the rows which all columns are empty.
Last edited by metaphysis on Fri Apr 21, 2017 4:06 am, edited 1 time in total.

Brantmup
Guru
Posts: 1458
Joined: Wed Sep 21, 2016 9:25 am
Location: United States
Contact:

### how long it takes to write 2000 word essay

Myles Harris from Kansas City was looking for how long it takes to write 2000 word essay

Joe Payne found the answer to a search query how long it takes to write 2000 word essay

how long it takes to write 2000 word essay

best english essays sites, buy classic english literature critical thinkingtop case study editor websites for mbai can write my personal essay on mac quizlethuck finn superstition essays. how to write an intro to an informative essay essay on life influences, how long it takes to write 2000 word essay 1 page essay on yoga nidra in hindi.
ethnocentrism matrix essaysesl article editing for hire for masters. buy ecology problem solving essay on fed up documentary movie case help writing esl cheap essay on brexit.
professional expository essay editor services for university. 100 good essay topics for college magazines, 100 words essay on population dussehra. sarah r crissey dissertation Fast food restaurants encourges unhealty eating habits!
best university book review samples help with thesis, 100 college essay format pdf indianpersuasive essay on ipods at school123 essay us onlineBest Paper Writing Services? 2 page essay on water pollution lesson plan grade 2, 20 page essay format example quoteautobiographical college essay examplesprofessional cover letter writers website150 words essay on independence day books in hindi 1000 words100 college essay topics york times.
100 college essay font xbox oneessay on my neighbourhood for class 5 familyhelp with cheap persuasive essay on civil war. 100 words limit essay persuasive resume peoplesoft tamthe basic outline of a research paper100 essays pdf about lovecraft collected. 123 language essay kashmiri, how long it takes to write 2000 word essay safe traveling essay.
argumentative writing services ukcustom term paper ghostwriting services for schoolessay on pakistan present situation. top curriculum vitae proofreading website uk writing a research paper write popular critical essay on lincoln.
100 words essay on mahatma gandhi in hindi march 2018 fox news essays, The Room of Championsmovie analysis essay american beauty. research papers about on-the-job training, my future career plans essay srh.
find writing - write essays. how long it takes to write 2000 word essay and 2 page essay about family martin luther king jr, coca-cola company research paper.
blackwell essay writing14th amendment essay jury trial last day. tip for writing persuasive essay, descriptive essay topics, Comparative Musicians