Page 1 of 1
466 - Mirror, Mirror
Posted: Wed Oct 16, 2002 3:25 pm
by luzi82
I don't know why WA.
please help.
Code: Select all
#include <iostream.h>
bool happy[2][10][10];
int size;
bool funny( bool v1, int v2 ) {
int x, y, ix, iy;
bool r90, r180;
if ( v2 % 180 != 0 ) {
r90 = true;
} else {
r90 = false;
}
if ( v2 >= 180 ) {
r180 = true;
} else {
r180 = false;
}
for ( y = 0 ; y < size ; y++ ) {
for ( x = 0 ; x < size ; x++ ) {
iy = (v1)?(size-1-y):y;
if ( r90 ) {
ix = size - 1 - iy;
iy = x;
} else {
ix = x;
}
if ( r180 ) {
ix = size -1 - ix;
iy = size -1 - iy;
}
if ( happy[0][y][x] != happy[1][iy][ix] ) {
return(false);
}
}
}
return(true);
}
main() {
int i, j, count = 0;
char input;
while ( cin >> size ) {
count++;
for ( i = 0 ; i < size ; i++ ) {
for ( j = 0 ; j < size ; j++ ) {
cin >> input;
if ( input == 'X' || input == 'x' ) {
happy[0][i][j] = true;
} else {
happy[0][i][j] = false;
}
}
for ( j = 0 ; j < size ; j++ ) {
cin >> input;
if ( input == 'X' || input == 'x' ) {
happy[1][i][j] = true;
} else {
happy[1][i][j] = false;
}
}
}
if ( funny( false , 0) ) {
cout << "Pattern " << count << " was preserved.";
} else if ( funny( false , 90) ) {
cout << "Pattern " << count << " was rotated 90 degrees.";
} else if ( funny( false , 180) ) {
cout << "Pattern " << count << " was rotated 180 degrees.";
} else if ( funny( false , 270) ) {
cout << "Pattern " << count << " was rotated 270 degrees.";
} else if ( funny( true , 0) ) {
cout << "Pattern " << count << " was reflected vertically.";
} else if ( funny( true , 90) ) {
cout << "Pattern " << count << " was reflected vertically and rotated 90 degrees.";
} else if ( funny( true , 180) ) {
cout << "Pattern " << count << " was reflected vertically and rotated 180 degrees.";
} else if ( funny( true , 270) ) {
cout << "Pattern " << count << " was reflected vertically and rotated 270 degrees.";
} else {
cout << "Pattern " << count << " was improperly transformed.";
}
cout << endl;
}
}
466 WA
Posted: Wed Mar 26, 2003 3:02 pm
by afonsocsc
This one is strange, don't know why the wa!
There must be something in the input...
[c]
...
[/c]
Posted: Thu Mar 27, 2003 4:26 pm
by afonsocsc
solved!
466 - Mirror, Mirror
Posted: Sun Nov 23, 2003 8:42 am
by jaywinyeah
I am having some problems with this problem. It seems like an easy problem, but I am getting WA. Are there any tricks to this problem? Does any body have some hard input I could use? Also, is a 270 degree rotation less work or more work than 180 degree rotation?
Is this the proper order I should check:
preserved
rotated 90 degrees
rotated 180 degrees
rotated 270 degrees
reflected vertically
reflected vertically and rotated 90 degrees
reflected vertically and rotated 180 degrees
reflected vertically and rotated 270 degrees
improperly transformed
Are there any other outputs?
Thanks
466 - bad input cases
Posted: Sun Sep 05, 2004 10:59 pm
by CrazyTerabyte
This problem is bad described, or has bad input cases.
The problem description says: "Light squares will be indicated by a dot (period), while dark squares will be represented with an X."
However, in input cases the dark squares are represented with "X" or "x". This is really bad, because the problem says it will be represened with "X". So, I have a lot of wrong answers, a lot of time wasted, and the correct algorithm.
I think something must be changed. Or the problem description should be changed to "...dark squares will be represented with the X (don't care about the case)" or something like this. Or the input cases must be fixed to have only "X" and no "x".
If nothing changes, this won't be a programming contest, but will be a guess what I have here contest. And I'm a programming contestant.
Posted: Tue Sep 07, 2004 11:31 pm
by Andrew Neitsch
I highly doubt that the input is incorrect. If you email
problemset@acm.uva.es, they can check it for you, but at least 93% of all such claims are absurdly false.
Posted: Wed Sep 08, 2004 3:17 am
by CrazyTerabyte
Yes, the input is incorrect. I read the input with this line:
[c]if(scanf(" %[.X] %[.X]",antes,depois)!=2) while(1);[/c]
The infinite loop was added for testing purposes. If I read the input with this code:
[c]if(scanf(" %[.xX] %[.xX]",antes,depois)!=2) while(1);[/c]
I get accepted.
Posted: Wed Sep 08, 2004 4:38 am
by Andrew Neitsch
I don't believe you. I've done the same thing, where I was convinced the input was wrong, that all I had to do was change one line in my input routine to go from WA to AC; but I contacted the people who run the judge, and they checked, and the input was fine.
If there really is a problem, email the judge people, and they will check if there is a problem, and if there is one, they will fix it.
Posted: Wed Sep 08, 2004 8:52 am
by Carlos
Actually there was a problem, X were lower-case. We've solved it.
Carlos.
466: Mirror, mirror: Wrong Answer??
Posted: Fri May 06, 2005 3:38 pm
by OuFeRRaT
I need help.
Is there anything hidden in this problem? I get the correct results with the sample input. I supose that:
cost(preserved) < cost(90degrees) < cost(180degrees) < cost(270degrees) < cost(verticalreflection) < cost(verticalreflection+90degrees) < cost(verticalreflection+180degrees) < cost(verticalreflection+270degrees)
is this correct?
thanks a lot for your help
466 - Mirror, Mirror - Home Made Input to Help You!
Posted: Wed Jul 06, 2005 8:38 am
by Jemerson
I'd got some trouble on this problem and couldn't find some extra input samples, so i've created a few that helped me and hope they help you too.
Input:
Code: Select all
8
........ ....X..X
..XXX... ....X..X
..XXX... .XX.X..X
........ .XX.XXXX
XXXXXXXX .XX.XXXX
...XX... ....X..X
...XX... ....X..X
XXXXXXXX ....X..X
10
.......... ..........
.......... ..........
.......... ..........
.......... ....XX....
.......... ..........
.......... ..........
....XX.... ..........
.......... ..........
....X..... ..X.......
.......... ..........
10
.......... ..........
.......... ..........
.......... ..........
.......... ..X.......
.......... ...X......
.......... ...X......
....XX.... ..........
...X...... ..........
.......... ..........
.......... ..........
10
XXXXXXXXXX X........X
.......... .........X
.......... .........X
.......... .........X
.......... ...X.....X
.......... ...X.....X
....XX.... ..X......X
...X...... .........X
.......... .........X
.........X .........X
1
. .
1
X X
1
X .
1
. X
2
.X X.
.X X.
3
X.. ..X
.X. .X.
..X X..
3
X.X ..X
.X. .X.
..X X.X
3
X.X X..
XX. .XX
..X X.X
3
X.X XX.
XX. .X.
..X X.X
Output:
Code: Select all
Pattern 1 was reflected vertically and rotated 90 degrees.
Pattern 2 was improperly transformed.
Pattern 3 was rotated 90 degrees.
Pattern 4 was reflected vertically and rotated 270 degrees.
Pattern 5 was preserved.
Pattern 6 was preserved.
Pattern 7 was improperly transformed.
Pattern 8 was improperly transformed.
Pattern 9 was rotated 180 degrees.
Pattern 10 was rotated 90 degrees.
Pattern 11 was rotated 90 degrees.
Pattern 12 was rotated 180 degrees.
Pattern 13 was reflected vertically and rotated 90 degrees.
Good Luck for all
Re: 466 - Mirror, Mirror - Home Made Input to Help You!
Posted: Sun Jul 12, 2009 4:52 pm
by Obaida
Some one plz help me. i tested all d case my code pass them well. but gets wA..(i can't figure out the reason

)?
here is my code
Code: Select all
#include<stdio.h>
#include<string.h>
int n;
char st1[11][11],st2[11][11],res[11][11],temp[11][11];
bool compare()
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(res[i][j]!=st2[i][j])
return 0;
return 1;
}
void rotation_90()
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
res[i][j]=st1[n-j-1][i];
}
void rotation_270()
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
res[j][i]=st1[i][n-j-1];
}
void rotation_180()
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
res[n-i-1][j]=st1[i][n-j-1];
}
void vertical_reflection()
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
res[n-j-1][i]=st1[j][i];
}
bool preserved()
{
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(st1[i][j]!=st2[i][j])
return 0;
return 1;
}
int main()
{
int ca=0,i;
while(scanf("%d%*c",&n)==1)
{
for(i=0;i<n;i++)scanf("%s %s",&st1[i],&st2[i]);
printf("Pattern %d was ",++ca);
if(preserved())puts("preserved.");
else
{
rotation_90();
if(compare())puts("rotated 90 degrees.");
else
{
rotation_180();
if(compare())puts("rotated 180 degrees.");
else
{
rotation_270();
if(compare())puts("rotated 270 degrees.");
else
{
vertical_reflection();
if(compare())puts("reflected vertically.");
else
{
for(i=0;i<n;i++){strcpy(temp[i],res[i]);res[i][n]=NULL;strcpy(st1[i],res[i]);temp[i][n]=NULL;}
rotation_90();
if(compare())puts("reflected vertically and rotated 90 degrees.");
else
{
for(i=0;i<n;i++)strcpy(st1[i],temp[i]);
rotation_180();
if(compare())puts("reflected vertically and rotated 90 degrees.");
else
{
for(i=0;i<n;i++)strcpy(st1[i],temp[i]);
rotation_270();
if(compare())puts("reflected vertically and rotated 270 degrees.");
else puts("improperly transformed.");
}
}
}
}
}
}
}
}
return 0;
}
Re: 466 Mirror Mirror
Posted: Sat Nov 28, 2009 5:00 pm
by Angeh
or
preserved
rotated 90 degrees
rotated 180 degrees
rotated 270 degrees
reflected vertically
rotated 270 degrees and reflected vertically
rotated 180 degrees and reflected vertically
rotated 90 degrees and reflected vertically
improperly transformed
Re: 466 - NEED TEST CASES
Posted: Mon Apr 13, 2015 4:10 pm
by BISHALBISWAS
Getting WA with this code,but I checked with lots of test cases my code is working good....can anyone give me some critical test cases for this problem..??
my code is here:
Code: Select all
#include<stdio.h>
#include<iostream>
#include<vector>
#include<cstring>
#include<string>
#include<sstream>
using namespace std;
void combine(int n);
bool rot90(int n);
bool rot180(int n);
bool rot270(int n);
bool same(int n);
bool reflx(int n);
string mains[11],transd[11],ref[11];
string temp;
int count=1,check;
bool flag;
void combine(int n)
{
for(int i=0;i<n;i++)
{
temp=mains[i];
ref[n-i-1]=temp;
}
return ;
}
bool rot90(int n)
{
flag=false;
char keep;
if(check==1)
{
for(int i=0;i<n;i++)
{
temp="";
for(int j=n-1;j>=0;j--)
{
keep=ref[j][i];
temp.push_back(keep);
}
if(temp!=transd[i])
{
flag=true;
break;
}
}
}
else
{
for(int i=0;i<n;i++)
{
temp="";
for(int j=n-1;j>=0;j--)
{
keep=mains[j][i];
temp.push_back(keep);
}
if(temp!=transd[i])
{
flag=true;
break;
}
}
}
if(flag==false and check==0)
printf("Pattern %d was rotated 90 degrees.\n",count++);
else if(flag==false and check==1)
printf("Pattern %d was reflected vertically and rotated 90 degrees.\n",count++);
return flag;
}
bool rot180(int n)
{
flag=false;
if(check==1)
{
for(int i=n-1;i>=0;i--)
{
temp="";
for(int j=n-1;j>=0;j--)
{
temp.push_back(ref[i][j]);
}
if(temp!=transd[n-i-1])
{
flag=true;
break;
}
}
}
else
{
for(int i=n-1;i>=0;i--)
{
temp="";
for(int j=n-1;j>=0;j--)
{
temp.push_back(mains[i][j]);
}
if(temp!=transd[n-i-1])
{
flag=true;
break;
}
}
}
if(flag==false and check==0)
printf("Pattern %d was rotated 180 degrees.\n",count++);
else if(flag==false and check==1)
printf("Pattern %d was reflected vertically and rotated 180 degrees.\n");
return flag;
}
bool rot270(int n)
{
flag=false;
char keep;
if(check==1)
{
for(int i=n-1;i>=0;i--)
{
temp="";
for(int j=0;j<n;j++)
{
keep=ref[j][i];
temp.push_back(keep);
}
if(temp!=transd[n-i-1])
{
flag=true;
break;
}
}
}
else
{
for(int i=n-1;i>=0;i--)
{
temp="";
for(int j=0;j<n;j++)
{
keep=mains[j][i];
temp.push_back(keep);
}
if(temp!=transd[n-i-1])
{
flag=true;
break;
}
}
}
if(flag==false and check==0)
printf("Pattern %d was rotated 270 degrees.\n",count++);
else if(flag==false and check==1)
printf("Pattern %d was reflected vertically and rotated 270 degrees.\n",count++);
return flag;
}
bool same(int n)
{
flag=false;
for(int i=0;i<n;i++)
{
if(mains[i]!=transd[i])
{
flag=true;
break;
}
}
if(flag==false)
printf("Pattern %d was preserved.\n",count++);
return flag;
}
bool reflx(int n)
{
flag=false;
for(int i=0;i<n;i++)
{
if(mains[i]!=transd[n-i-1])
{
flag=true;
break;
}
}
if(flag==false)
printf("Pattern %d was reflected vertically.\n",count++);
return flag;
}
int main()
{
bool mark;
int n;
string a,b;
while(scanf("%d",&n)==1)
{
check=0;
for(int i=0;i<n;i++)
{
cin>>a>>b;
mains[i]=a;
transd[i]=b;
}
mark=same(n);
if(mark==1)
mark=rot90(n);
if(mark==1)
mark=rot180(n);
if(mark==1)
mark=rot270(n);
if(mark==1)
mark=reflx(n);
if(mark==1)
{
check=1;
combine(n);
mark=rot90(n);
if(mark==1)
mark=rot180(n);
if(mark==1)
mark=rot270(n);
if(mark==1)
printf("Pattern %d was improperly transformed.\n",count++);
}
}
return 0;
}