292 - Presentation Error

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

Moderator: Board moderators

Post Reply
algoJo
New poster
Posts: 37
Joined: Sun Dec 17, 2006 9:02 am

292 - Presentation Error

Post by algoJo »

Hi there, can anyone post more I/O set, and is this I/O set right??
INPUT

Code: Select all

11
1 2
Just one line?
Just one line?

2 2
The first characters of the alphabet are:
[abcde]
Here they come:
a b c d e
1 1
That's it: [abcde]
That's it: AbCdE
1 1
[2] and [3] make [5]
I guess 2 and 3 are less than 50.
1 1
The first character [a]
begoluh
1 1
The first character [abc]
ahbegoluhc
1 1
The first character [abcdefg]
xyz
1 1
The first character [abcdefg]
xyzabc
1 1
The first character [abcdefg]
xyzabcg
1 1
The first character [abc]
ahbegoluhcccc
1 1
susumu ueda [2] [a] [b] [c] [a] [b]
32 aihbihcihaihbihcih
OUTPUT

Code: Select all

Accepted
Wrong Answer
Presentation Error
Presentation Error
Wrong Answer
Presentation Error
Wrong Answer
Wrong Answer
Wrong Answer
Presentation Error
Wrong Answer
Thanks...^^
RED-C0DE
New poster
Posts: 16
Joined: Mon Mar 26, 2007 6:47 pm

Post by RED-C0DE »

Can somebody check this I/O?
RED-C0DE
New poster
Posts: 16
Joined: Mon Mar 26, 2007 6:47 pm

Post by RED-C0DE »

and this is my Output for those test-cases :

Code: Select all

Accepted
Wrong Answer
Presentation Error
Presentation Error
Wrong Answer
Wrong Answer
Wrong Answer
Wrong Answer
Wrong Answer
Wrong Answer
Presentation Error
adhirajsomani
New poster
Posts: 1
Joined: Sun Dec 06, 2009 2:45 pm

Re: 292 more I/O set please..

Post by adhirajsomani »

Hi,

I have been on this problem for days now, and I keep getting WA. Any special/border/tricky/unspecified-in-the-question test cases?

How should we handle lines that are only composed of white spaces?

If an essential is present in the submitout file, but crosses a line boundary over to the next line, is it counted? For example, [abcde] is the essential and the submitout file is
abc
de

Thanks.

Code: Select all

/*
Presentation Error, 292
Status: WA
*/

#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;

int nj, ns, tc, N;
char sub[12][100], jury[12][100], P[1000], T[100];

void straighten() {
    P[0] = 0;
    for(int i = 0; i < ns; i++)
        strcat(P, sub[i]);
}

int main() {
    scanf("%d\n", &tc);
    char temp[100];

    while(tc--) {

        // Input size
        gets(temp);
        nj = atoi(temp);
        int i;
        for(i = 1; temp[i-1] != ' '; i++)
            ;
        ns = atoi(temp+i);

        // Juryout input
        for(int j = 0; j < nj; j++) {
			gets(temp);
			if(temp[0] == 0) { j--; nj--; continue; }
            int i = 0;
            while(temp[i] == ' ' || temp[i] == '\t')
                 i++;
			if(temp[i] == 0) { j--; nj--; continue; }
            strcpy(jury[j], temp);
            while(temp[i])
				i++;
			while(temp[i-1] == ' ' || temp[i-1] == '\t')
				i--;
			jury[j][i] = 0;
		}
		
		// Submitout input
		for(int j = 0; j < ns; j++) {
			gets(temp);
			if(temp[0] == 0) { j--; ns--; continue; }
            int i = 0; 
            while(temp[i] == ' ' || temp[i] == '\t')
                i++;
			if(temp[i] == 0) { j--; ns--; continue; }
            strcpy(sub[j], temp);
            while(temp[i])
				i++;
			while(temp[i-1] == ' ' || temp[i-1] == '\t')
                i--;
            sub[j][i] = 0;
		}
		
		// Accepted?
		if(nj == ns) {
			char cmp[100];
            int i;
            for(i = 0; i < nj; i++) {
				int p = 0;
				for(int j = 0; jury[i][j]; j++)
					if(jury[i][j] != '[' && jury[i][j] != ']')
						cmp[p++] = jury[i][j];
				cmp[p] = 0;
				if(strcmp(cmp, sub[i]))
					break;
			}
			if(i == nj) {
				printf("Accepted\n");
				continue;
			}
		}

	    // Convert to uppercase
        for(int i = 0; i < nj; i++)
            for(int j = 0; jury[i][j]; j++)
                jury[i][j] = toupper(jury[i][j]);
        for(int i = 0; i < ns; i++)
            for(int j = 0; sub[i][j]; j++)
                sub[i][j] = toupper(sub[i][j]);

        // WA / Presentation Error?
        straighten();
        char *ptr = P;
        for(int i = 0; i < nj; i++) {
            for(int j = 0; jury[i][j]; j++)
                if(jury[i][j] == '[') {
                    for(N = 0, ++j; jury[i][j] != ']'; j++)
                        T[N++] = jury[i][j];
                    T[N] = 0;
                    ptr = strstr(ptr, T);
                    if(!ptr) {
                        printf("Wrong Answer\n");
                        goto end;
                    }
                    ptr += N;
                }
        }
        
		printf("Presentation Error\n");
        
		end: {
            continue;
        }
    }
    return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 292 more I/O set please..

Post by brianfry713 »

Input:

Code: Select all

1
1 2
[abcde]
abc
de
AC output:

Code: Select all

Wrong Answer
Check input and AC output for thousands of problems on uDebug!
RosetteBravo
New poster
Posts: 1
Joined: Sat Jan 24, 2015 4:07 pm

Re: 292 - Presentation Error

Post by RosetteBravo »

I got a WA problem with my program. Can someone, whose program was accepted, run this program with the following input and post the output?
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 292 - Presentation Error

Post by metaphysis »

Any special or critical test cases? My code always got WA, I tried the test cases on uDebug, It's OK.
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 292 - Presentation Error

Post by metaphysis »

Anyone who solved UVa 292 can have a look at my code? After several submits, I have no clue why my solution get Wrong Answer.

Code: Select all

#include <bits/stdc++.h>

using namespace std;

vector<string> En;
string jury, submit;

void removeTrailingEmptyLines(string &s)
{
    while (s.length() >= 2 && s[s.length() - 1] == '\n' && s[s.length() - 2] == '\n')
        s.pop_back();
}

void toUpper(string &s)
{
    for (int i = 0; i < s.length(); i++)
        if (isalpha(s[i]))
            s[i] = (char)(toupper(s[i]));
}

void addEssential(string &s)
{
    int idx = 0;
    while (idx < s.length())
    {
        if (s[idx] == '[')
        {
            idx++;
            string block;
            while (s[idx] != ']')
            {
                block += s[idx];
                idx++;
            }
            toUpper(block);
            En.push_back(block);
        }
        idx++;
    }
}

bool dfs(int i, int j)
{
    if (j == En.size()) return true;
    int idx = i;
    while (idx < submit.length())
    {
        idx = submit.find(En[j], idx);
        if (idx != submit.npos)
        {
            idx += En[j].length();
            if (dfs(idx, j + 1)) return true;
        } 
    }
    
    return false;
}

bool identical(string &s, string &t)
{
    int i = 0, j = 0;
	while (i < s.length() && j < t.length())
		if (s[i] == '[' || s[i] == ']') i++;
		else if (s[i] == t[j]) i++, j++;
		else return false;
	if (i < s.length() && s[i] == ']') i++;
	return i == s.length() && j == t.length();
}

int main(int argc, char *argv[])
{
    int cases, n1, n2;
    string line;

    cin >> cases;
    for (int cs = 1; cs <= cases; cs++)
    {
        cin >> n1 >> n2;
        cin.ignore(1024, '\n');

        jury.clear(), submit.clear(), En.clear();
        for (int i = 1; i <= n1; i++)
        {
            getline(cin, line);
            addEssential(line);
            while (line.length() > 0 && isspace(line.back())) line.pop_back();
            jury += line;
            jury += '\n';
        }

        for (int i = 1; i <= n2; i++)
        {
            getline(cin, line);
            while (line.length() > 0 && isspace(line.back())) line.pop_back();
            submit += line;
            submit += '\n';
        }

        removeTrailingEmptyLines(jury);
        removeTrailingEmptyLines(submit);

        if (identical(jury, submit))
        {
            cout << "Accepted\n";
            continue;
        }
        
        toUpper(submit);

        if (dfs(0, 0)) cout << "Presentation Error\n";
        else cout << "Wrong Answer\n";
     }
    
    return 0;
}
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 292 - Presentation Error

Post by metaphysis »

A stupid error.
Try input:

Code: Select all

15
0 1
 
1 2
Just one line?
Just one line?

1 2
Just one []line?
Just one line?

2 2
The first characters of the alphabet are:
[abcde]
Here they come:
a b c d e
1 1
That's it: [ abcde]
That's it: AbCdE
1 1
[2] and [3] make [5]
I guess 2 and 3 are less than 50.
1 1
The first character [a]
begoluh
1 1
The first character [abc]
ahbegoluhc
1 1
The first character [abcdefg]
xyz
1 1
The first character [abcdefg]
xyzabc
1 1
The first character [abcdefg]
xyzabcg
1 1
The first character [abc]
ahbegoluhcccc
1 1
susumu ueda [2] [a] [b] [c] [a] [b]
32 aihbiachcihaihbihcih
1 5
[abcde] [de]
abcde

[de]


4 2
aas

ee

aassssss
ee
Accepted output:

Code: Select all

Accepted
Accepted
Accepted
Wrong Answer
Presentation Error
Presentation Error
Wrong Answer
Wrong Answer
Wrong Answer
Wrong Answer
Wrong Answer
Wrong Answer
Presentation Error
Presentation Error
Presentation Error
Post Reply

Return to “Volume 2 (200-299)”