142 - Mouse Clicks
Moderator: Board moderators
-
Chung Ha, Yun
- New poster
- Posts: 19
- Joined: Tue Jul 16, 2002 5:56 pm
- Location: Seoul
- Contact:
^^
Thank you
strain my eyes.........................FULL SEARCHING^-^
Homepage : http://www.sozu.pe.kr
-
Chung Ha, Yun
- New poster
- Posts: 19
- Joined: Tue Jul 16, 2002 5:56 pm
- Location: Seoul
- Contact:
Huk
Huk..............
I fixed followed code.
Ha Ha.............. Sorry... my mistake ToT
Very large mistake!!!
Thank you very much El-idioto
I fixed followed code.
And I got Accepted.printf("%3c", (char)(i + 49)); -> printf("%3d", i + 1);
Ha Ha.............. Sorry... my mistake ToT
Very large mistake!!!
Thank you very much El-idioto
Homepage : http://www.sozu.pe.kr
142 Mouse click
I am getting WA with this problem.
Please help me by giving some more input output or you can tell some special conditions of this problem.
thanks
Please help me by giving some more input output or you can tell some special conditions of this problem.
thanks
O! long time no reply!! (very lazy board
)
Ok here is some Input please use you AC code and tell me there output.
I think at least some people here solved this problem.
Ok here is some Input please use you AC code and tell me there output.
I think at least some people here solved this problem.
Code: Select all
I 216 28
R 22 19 170 102
I 40 150
I 96 138
I 36 193
R 305 13 425 103
I 191 184
I 387 200
R 266 63 370 140
I 419 134
I 170 102
I 40 152
I 40 172
I 60 152
M 50 50
M 236 30
M 403 167
M 330 83
M 370 50
M 330 83
M 50 162
#
Output from my AC code:A1 wrote:Code: Select all
I 216 28 R 22 19 170 102 I 40 150 I 96 138 I 36 193 R 305 13 425 103 I 191 184 I 387 200 R 266 63 370 140 I 419 134 I 170 102 I 40 152 I 40 172 I 60 152 M 50 50 M 236 30 M 403 167 M 330 83 M 370 50 M 330 83 M 50 162 #
Code: Select all
A
1
6 7
C
B
C
9 10 11
142input-way
I saw fix mistake post
Is my input way ok ?
Is my input way ok ?
Code: Select all
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std ;
struct Point {
double x ;
double y ;
} point[100] ;
int inx = -1 , tmp = 0 ;
int InputI (){ cin >> point[++inx].x >> point[inx].y ; }
int InputR ( char ar[600][600] ) {
int i , j , a , b , c , d ;
cin >> a >> b >> c >> d ;
++tmp ;
for ( i=a ; i<=c ; i++ )
for ( j=b ; j<=d ; j++ )
ar[i][j]=tmp ;
}
char s[2] ;
double dis ( double x , double y , double tx , double ty ){ return sqrt((x-tx)*(x-tx)+(y-ty)*(y-ty)) ; }
int Answer ( char ar[600][600] ) {
int a , b ;
cin >> a >> b ;
if ( ar[a][b] )
putchar(ar[a][b]+'A'-1) ;
else {
int i ;
double min = 999999.0 ;
for ( i=0 ; i<=inx ; i++ )
if ( dis ( (double)a , (double)b , point[i].x , point[i].y ) < min )
min = dis ( (double)a , (double)b , point[i].x , point[i].y ) ;
for ( i=0 ; i<=inx ; i++ )
if ( dis ( (double)a , (double)b , point[i].x , point[i].y ) == min )
cout << " " << i+1 ;
}
putchar('\n') ;
}
int Q ( char ar[600][600] ) {
if ( s[0]=='I' )
InputI ( ) ;
else if ( s[0]=='R')
InputR ( ar ) ;
else
Answer ( ar ) ;
}
int main () {
while ( cin >> s ){
char ar[600][600]={0} ;
inx = -1 , tmp = 0 ;
Q(ar) ;
while ( cin >> s && s[0]-'#' )
Q(ar) ;
}
} 142 mouse clicks WA - tricky input?
Hi,
I just check if some icons are overlaped by regions, if is, mark it.
For every click, I check if a region is selected, if is, print it, otherwise
print closest visible icons.
Anyone gets AC after rejudge?
I just check if some icons are overlaped by regions, if is, mark it.
For every click, I check if a region is selected, if is, print it, otherwise
print closest visible icons.
Anyone gets AC after rejudge?
Code: Select all
#include<stdio.h>
class rg{
public:
int sx,sy,ex,ey;
bool inrg(int x,int y){
if(sx<=x && x<=ex && sy<=y && y<=ey)
return true;
return false;
}
void get(){
scanf("%d %d %d %d",&sx,&sy,&ex,&ey);
}
}rg[250];
class ic{
public:
int cx,cy;
int dis(int x,int y){
return (cx-x)*(cx-x)+(cy-y)*(cy-y);
}
void get(){
scanf("%d %d",&cx,&cy);
}
}ic[500];
main(){
int i,j,x,y,min,in=0,rn=0,mark[500];
char c[10000];
while(scanf("%s",c)!=EOF && *c!='#'){
if(*c=='I'){
mark[in]=0;
ic[in].get();
for(i=0;i<rn;i++)
if(rg[i].inrg(ic[in].cx,ic[in].cy))
mark[in]=1;
in++;
}
else if(*c=='R'){
rg[rn].get();
for(i=0;i<in;i++)
if(rg[rn].inrg(ic[i].cx,ic[i].cy))
mark[i]=1;
rn++;
}
else if(*c=='M'){
scanf("%d %d",&x,&y);
for(i=rn-1;i>=0;i--)
if(rg[i].inrg(x,y))break;
if(i>=0){
printf("%c\n",'A'+i);
continue;
}
min=100000000;
for(i=0;i<in;i++)
min<?=ic[i].dis(x,y);
for(i=0;i<in;i++)
if(min==ic[i].dis(x,y))
printf("%3d",i+1);
puts("");
}
}
}
For those,who r trying to solve 142.....
The problem description is a bit ambiguous.While trying to solve this problem,i thought of input order....such as
if a region defined earlier than an icon,what will be happened.If this icon stays in that rectengular region,what will be on the top?
The icon or the region?Normal thinking says that the icon must be on the top as it defined later.But after sm WA,I checkd the visiblity
of icons after all input r given.& got AC.This means if an icon & a region stays at same place,the region is on the
top & the input order is not fact here.
if a region defined earlier than an icon,what will be happened.If this icon stays in that rectengular region,what will be on the top?
The icon or the region?Normal thinking says that the icon must be on the top as it defined later.But after sm WA,I checkd the visiblity
of icons after all input r given.& got AC.This means if an icon & a region stays at same place,the region is on the
top & the input order is not fact here.
khobaib
Read the problem description again:
If an icon is within a rectangular region , then the region is always on top of the icon.
I think you are right about checking visibility of icons after taking in all the region and icon specifications. Edit: I double-checked my code which got WA after rejudge (previously AC), and it does check visibility of icons after taking all region and icon specifications. The problem is somewhere else.
Code: Select all
Note that regions always overlap icons so that obscured icons need not be consideredI think you are right about checking visibility of icons after taking in all the region and icon specifications. Edit: I double-checked my code which got WA after rejudge (previously AC), and it does check visibility of icons after taking all region and icon specifications. The problem is somewhere else.
Last edited by chunyi81 on Sun Dec 25, 2005 10:00 am, edited 2 times in total.
mf, what should be the output for this test case?
According to the problem specifications, the mouse click at 200 200 for this test case does not select anything at all since it does not select the only region in this test case and the only icon the mouse click can select is not visible. What should be the output for such test cases?
Here is my code (I changed it to handle cases like the one I have given above, but still WA.)
Where is the error in my code? For each line of input, my program checks if the first non-whitespace character is 'R', 'I', 'M' or '#', and then if its R, I or M it processes accordingly. The visibility of icons is only checked when a mouse click ('M') is encountered.
Code: Select all
I 170 102
R 22 19 170 102
M 200 200
#
Here is my code (I changed it to handle cases like the one I have given above, but still WA.)
Code: Select all
Cut after AC. Thanks for all the help.
Last edited by chunyi81 on Mon Dec 26, 2005 4:23 am, edited 1 time in total.
Both my programs (old and new ACs) print a blank line.chunyi81 wrote: mf, what should be the output for this test case?
Code: Select all
I 170 102 R 22 19 170 102 M 200 200 #
Main problem with your code, I think, is that you use floating-point numbers. This can easily lead to all sorts of trouble. Try to use just integers.
Secondly, this part of your code still may print obscured icons, check it carefully.
Code: Select all
if (icon >= 0) {
printf("%3d",icon + 1);
for (j = icon + 1;j < icons;j++) {
distance = get_distance(x,y,xval[j],yval[j]);
if (distance == min)
printf("%3d",j + 1);
}
}