10010 - Where's Waldorf?

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

Moderator: Board moderators

sith
Learning poster
Posts: 72
Joined: Sat May 19, 2012 7:46 pm

Re: 10010 - Where's Waldorf?

Post by sith »

Hello
Can anybody explain, there is Waldorf(2 5) in the promblem example?
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10010 - Where's Waldorf?

Post by brianfry713 »

Down and to the right.
Check input and AC output for thousands of problems on uDebug!
sherifibrahim44
New poster
Posts: 4
Joined: Thu Feb 21, 2013 11:29 pm

Re: 10010 - Where's Waldorf?

Post by sherifibrahim44 »

Hi,

Code: Select all

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

Re: 10010 - Where's Waldorf?

Post by brianfry713 »

Input:

Code: Select all

10

3 3
Hpv
eHC
uoN
6
e
oC
N
e
eH
o

9 8
jajPjpVd
WJVhyowL
YZMZrqDG
rxpMiqCo
RKGCzlmG
KRjRKZKR
DIMJfQmy
dcAhazYQ
uOLWukMH
4
Q
QaW
m
au

7 10
wIkaNboMsi
BrFaMVJYgN
LZFuOWEqrW
LqZPPAYELF
guryfqoNxW
lSvrzLausE
nOFqhTIEKO
7
Yq
rEo
Ns
AqL
EN
u
ig

8 8
rAQcTNSH
tWwOiyNo
otEWWKMi
obcVgVDB
cxUdFFJZ
VlvPeyWb
XESIYRhg
VeCvGqwa
8
FVKy
Bi
Zbg
DFeIC
gVc
i
TiWgF
FdUxc

10 1
H
T
Y
a
A
u
K
O
c
f
7
u
TY
T
KOcf
A
O
c

8 10
gcTEbJMLbx
gwvWUEbvoT
EywPEmlsGc
ibRGzYHZLF
EBDWkJIHMI
PsICIkAEgO
CmOoipJWdM
hAjoghGuqz
10
IY
goj
IE
MEJ
i
L
zP
T
ZHY
IkAE

4 4
CLcj
GHtt
xhoP
rABa
3
t
LH
jcL

8 8
ZKlMdfkk
eJIsjriD
CFZWCndg
AvEIVNio
HDnODFDR
cpDwBFEZ
pwevqRnZ
aXQDjGDc
10
inVO
EZIl
vEIVNi
Z
j
c
D
D
Il
Ri

1 2
uI
1
I

1 1
B
7
B
B
B
B
B
B
B
AC output:

Code: Select all

2 1
3 2
3 3
2 1
2 1
3 2

3 6
7 6
3 3
8 5

2 8
3 9
2 10
4 6
4 8
3 4
1 10

5 6
4 8
5 8
4 7
4 5
2 5
1 5
5 5

6 1
2 1
2 1
7 1
4 1
8 1
9 1

4 1
8 5
4 1
3 6
4 1
1 8
4 5
1 3
4 8
6 5

2 3
1 2
1 4

2 7
4 3
4 2
1 1
2 2
3 1
1 5
1 5
2 3
2 6

1 2

1 1
1 1
1 1
1 1
1 1
1 1
1 1
Check input and AC output for thousands of problems on uDebug!
rafal00785
New poster
Posts: 1
Joined: Sun Mar 16, 2014 10:59 pm

Re: 10010 - Where's Waldorf?

Post by rafal00785 »

Someone could help me with my code?
For all tests in this forum i have correct output but not getting AC :(
Can anyone tell me why?
Here is my code:

Code: Select all

Cut after Acc...
Example input

Code: Select all

1
3 3
Hpv
eHC
uoN
6
e
oC
N
e
eH
o
My output

Code: Select all

2 1
3 2
3 3
2 1
2 1
3 2

The correct output

Code: Select all

2 1
3 2
3 3
2 1
2 1
3 2
thewill
New poster
Posts: 6
Joined: Wed Dec 04, 2013 10:18 am

WA: 10010 - Where's Waldorf?

Post by thewill »

here is my code plzz look at it .... thanx

i have passed all the test cases in the uva forum as well then why wrong answer cant understand

#include<iostream>
#include<cstdio>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
#include<deque>
#include<iterator>
#include<assert.h>
#include<bitset>
#include<climits>
#include<ctime>
#include<complex>
using namespace std;
int slength,m,n,x,dir[]={-1,0,1},temp1,temp2;
char a[55][55];
string s1;

void convert()
{
int i;
for(i=0;i<slength;i++)
{
if(islower(s1))
{
s1=s1-32;
}
}
}

int brutesearchforall(int s,int d,int newno)
{
int i,j,k;
if(a[s+temp1][d+temp2]==s1[newno])
{
if(newno+1==slength)
{
return 1;
}
else
{
if(brutesearchforall(s+temp1,d+temp2,newno+1))
{
return 1;
}
}
}
return 0;
}

int brutesearch1(int s,int d,int no)
{
int i,j,k;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(dir==0&&dir[j]==0)
{
continue;
}
if(a[s+dir][d+dir[j]]==s1[no])
{
temp1=dir;
temp2=dir[j];
if(no+1==slength)
{
return 1;
}
else
{
if(brutesearchforall(s+temp1,d+temp2,no+1))
{
return 1;
}
}
}
}
}
return 0;
}

int main()
{
int i,j,k,l,q,firstcase,flag,testcase,t;
scanf("%d",&testcase);
printf("\n");
for(t=0;t<testcase;t++)
{
if(t!=0)
{
printf("\n");
}
scanf("%d %d\n",&m,&n);
x=0;
firstcase=0;
flag=0;
for(i=0;i<55;i++)
{
for(j=0;j<55;j++)
{
a[j]='*';
}
}
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
cin>>a[j];
if(islower(a[j]))
{
a[j]=a[i][j]-32;
}
}
}
scanf("%d\n",&q);
for(k=1;k<=q;k++)
{
cin>>s1;
slength=s1.length();
convert();
flag=0;
x=0;
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
x=0;
if(a[i][j]==s1[0])
{
x++;
if(x==slength)
{
printf("%d %d\n",i,j);
flag=1;
}
else
{
if(brutesearch1(i,j,x))
{
printf("%d %d\n",i,j);
flag=1;
}
}
}
if(flag)
break;
}
if(flag)
break;
}
}
}
return 0;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10010 - Where's Waldorf?

Post by brianfry713 »

The outputs of two consecutive cases will be separated by a blank line. Don't print a blank line at the start of the output.
Check input and AC output for thousands of problems on uDebug!
mmahtias
New poster
Posts: 1
Joined: Mon Sep 29, 2014 2:37 am

Re: 10010 - Where's Waldorf?

Post by mmahtias »

Seems to be important to put empty lines only between consecutive cases, not after the last case. I overlooked that a few times...
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10010 - Where's Waldorf?

Post by brianfry713 »

Yes, it is always important to put the newline chars in the correct places.
Check input and AC output for thousands of problems on uDebug!
LazyTym
New poster
Posts: 31
Joined: Tue Jun 24, 2014 9:10 pm

Re: 10010 - Where's Waldorf? Why getting WA?????

Post by LazyTym »

every time getting WA.can anyone help to recognize bug in my code?

Code: Select all

#include<iostream>
#include<cctype>
#include <cstring>
#define MAX 51

using namespace std;
char s[MAX][MAX];
int num_row,num_col;


int SEARCH_WORD_LOCATION(string str,int sx,int sy) {

    int cur,parent,x,y,len;
    int dis[8]={1,-1,-num_col,+num_col,-num_col-1,-num_col+1,+num_col-1,+num_col+1};

    len=str.length();
    cur=(sx*num_col)+sy;
    parent=cur;

    for(int i=0;i<8;i++) {

        cur=parent+dis[i];
        x=cur/num_col;
        y=cur%num_col;

        //cout<<x<<"  "<<y<<"  fuck"<<endl;

        if(s[x][y]==str[1] && cur>0) {
            int flag=0;
            for(int j=2;j<len;j++) {
                cur=cur+dis[i];
                x=cur/num_col;
                y=cur%num_col;
                //cout<<x<<"  "<<y<<"  fuck............"<<endl;
                if(s[x][y]!=str[j])
                {
                    flag=1;
                    break;
                }
            }
            if(flag==1) continue;
            else return 1;
        }
    }
    return 0;

}


int main()
{
    //freopen("in.txt","r",stdin);
    int n,t;
    string k;
    cin>>t;
    while(t--) {
    cout<<endl;
    cin>>num_row>>num_col;
    for(int i=0;i<num_row;i++) {
        cin>>s[i];
        for(int j=0;j<num_col;j++) {
           s[i][j]=tolower(s[i][j]);
        }
    }

    cin>>n;
    int flag,sx,sy;
    for(int i=0;i<n;i++) {
        cin>>k;
        flag=0;
        for(int j=0;j<k.length();j++) {
            k[j]=tolower(k[j]);
        }
        for(int i=0;i<num_row;i++) {
            for(int j=0;j<num_col;j++) {
                if(s[i][j]==k[0]) {
                    sx=i;
                    sy=j;
                   //cout<<endl<<i<<" "<<j<<endl<<endl;
                   if(k.length()==1) {
                        cout<<i+1<<" "<<j+1<<endl;
                        flag=1;
                        break;
                    }
                    else {
                        if(SEARCH_WORD_LOCATION(k,sx,sy)==1) {
                            flag=1;
                            cout<<i+1<<"  "<<j+1<<endl;
                            break;
                        }
                    }
                }
                if(flag==1) break;
            }
            if(flag==1) break;
        }
        if(i!=n-1) cout<<endl;

    }
    }

    return 0;
}

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

Re: 10010 - Where's Waldorf?

Post by brianfry713 »

For the sample input:

Code: Select all

1

8 11
abcDEFGhigg
hEbkWalDork
FtyAwaldORm
FtsimrLqsrc
byoArBeDeyv
Klcbqwikomk
strEBGadhrb
yUiqlxcnBjf
4
Waldorf
Bambi
Betty
Dagbert
The correct output is:

Code: Select all

2 5
2 3
1 2
7 8
Your code is printing:

Code: Select all


2  5

2  3

1  2

7  8
Check input and AC output for thousands of problems on uDebug!
Mukit Chowdhury
Learning poster
Posts: 99
Joined: Fri Aug 17, 2012 9:23 pm
Location: Dhaka
Contact:

Re: 10010 - Where's Waldorf?

Post by Mukit Chowdhury »

Searched string will have to be found in a line. Totally missed this and got 5 WA. :(
Kekskruemel
New poster
Posts: 1
Joined: Sun Dec 20, 2015 2:59 pm

Re: 10010 - Where's Waldorf?

Post by Kekskruemel »

Hi,

I've got the same problem as many others here: WA and I don't know why :( All the testcases in this forum work fine...
If someone can find a tricky testcase, that doesn't work, pls post it.
Here is my Code:

Code: Select all


import java.util.Scanner;

class Main {
	
	static char [][] grid;
	static int outputRow ;
	static int outputCol;
	static boolean wordHere;
	static boolean outputFound;
	
	public static void main (String[] args)
	{
		Scanner scan = new Scanner (System.in);
		int numbCases = scan.nextInt();
		for (int testcase = 0; testcase < numbCases; testcase ++)
		{
			//getting input
			int numbRows = scan.nextInt();
			int numbCols = scan.nextInt();
			outputRow = 0;
			outputCol = 0;
			grid = new char[numbRows][numbCols];
			scan.nextLine();
			for(int i=0; i<numbRows; i++)
			{
				String line = scan.nextLine();
				line = line.toLowerCase();
				grid[i] = line.toCharArray();
			}
			int numbWords = scan.nextInt();
			scan.nextLine();
			for(int thisWord=0; thisWord<numbWords; thisWord++)
			{
				String word = scan.nextLine();
				word = word.toLowerCase();
				char firstLetter = word.charAt(0);
				int wordLength = word.length();
				outputFound = false;
				//Looking for this word in the grid
				for (int i=0; i<numbRows && !outputFound; i++)
				{
					for(int j=0; j<numbCols && !outputFound; j++)
					{
						if(firstLetter != grid[i][j])
								continue;
						wordHere = true;
						if(i+wordLength <= numbRows )
						{
							// Wort nach unten suchen //direction = down
							for(int k=0; k<wordLength; k++)
							{
								if(grid[i+k][j] != word.charAt(k))
								{
									wordHere = false;
									break;
								}
							}
							clean(i, j);
							// diagonal nach links unten); direction = digonally: to the left + down 
							if(j+1-wordLength >=0 && !outputFound)	//Das +1 kommt durch den Umstand, dass j von 0 ab zaehlt und wordlength nicht
							{
								for(int k=0; k<wordLength; k++)
								{
									if(grid[i+k][j-k] != word.charAt(k))
									{
										wordHere = false;
										break;
									}
								}
								clean(i, j);
							}
							// diagonal nach rechts unten); direction = diagonally: to the right and down 
							if(j+wordLength <= numbCols && !outputFound)
							{
								for(int k=0; k<wordLength; k++)
								{
									if(grid[i+k][j+k] != word.charAt(k))
									{
										wordHere = false;
										break;
									}
								}
								clean(i, j);
							}
							
							
						}
						if (j+wordLength <= numbCols && !outputFound)
						{
							// Wort nach rechts suchen; direction = right
							for(int k=0; k<wordLength; k++)
							{
								if(grid[i][j+k] != word.charAt(k))
								{
									wordHere = false;
									break;
								}
							}
							clean(i, j);
						}
						if(i+1-wordLength >= 0)
						{
							// Wort nach oben geschrieben suchen; direction = up
							for(int k=0; k<wordLength; k++)
							{
								if(grid[i-k][j] != word.charAt(k))
								{
									wordHere = false;
									break;
								}
							}
							clean(i, j);
							//diagonal nach links oben); direction = diagonally, to the left & up
							if(j+1-wordLength >=0 && !outputFound)
							{
								for(int k=0; k<wordLength; k++)
								{
									if(grid[i-k][j-k] != word.charAt(k))
									{
										wordHere = false;
										break;
									}
								}
								clean(i, j);
							}
							//diagonal nach rechts oben); direction = diagonally to the right and up
							if(j+wordLength <= numbCols && !outputFound)
							{
								for(int k=0; k<wordLength; k++)
								{
									if(grid[i-k][j+k] != word.charAt(k))
									{
										wordHere = false;
										break;
									}
								}
								clean(i, j);
							}
							
						}
						// Wort nach links geschrieben suchen; direction = to the left
						if(j+1-wordLength >= 0)
						{
							for(int k=0; k<wordLength; k++)
							{
								if(grid[i][j-k] != word.charAt(k))
								{
									wordHere = false;
									break;
								}
							}
							clean(i, j);
						} 
						
					}
				}
				System.out.print((outputRow+1) + " " + (outputCol+1));
				if(thisWord!= numbWords-1 || testcase!=numbCases-1)
					System.out.println();
			}
		if(testcase != numbCases-1)
			System.out.println();
		}
	}
	
	private static int clean (int i, int j){
		if(wordHere == true)
		{
			outputRow = i;
			outputCol = j;
			outputFound = true;
		}
		wordHere = true;
		
		return 0;
	}
}
Post Reply

Return to “Volume 100 (10000-10099)”