Page 2 of 4

^^

Posted: Fri Feb 27, 2004 12:48 am
by Chung Ha, Yun
Thank you :D

:o strain my eyes.........................FULL SEARCHING^-^

Huk

Posted: Fri Feb 27, 2004 1:43 am
by Chung Ha, Yun
Huk.............. :-?

I fixed followed code.
printf("%3c", (char)(i + 49)); -> printf("%3d", i + 1);
And I got Accepted.

Ha Ha.............. Sorry... my mistake ToT

Very large mistake!!!

Thank you very much El-idioto :D

142 Mouse click

Posted: Sat Dec 04, 2004 10:26 am
by A1
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

Posted: Sun Dec 12, 2004 9:04 am
by A1
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.

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
#

Posted: Sun Dec 12, 2004 9:57 am
by shamim
A1, I don't have my AC code with me, but I can tell you one set of critical case could be the consideration of boundary points, that is clicks falling on boundary.

Posted: Sun Dec 12, 2004 3:08 pm
by A1
I consider that But sitll WA :(
so some one please give me those outputs.

Posted: Sun Dec 12, 2004 4:02 pm
by chunyi81
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
#
Output from my AC code:

Code: Select all

A
  1
  6  7
C
B
C
  9 10 11
Hope this helps.

Posted: Sun Dec 19, 2004 9:37 am
by A1
Oh god !
It has multiple test set of input. I thought that there will be one set of input and get wrong answer again and again!!!!

thanks chunyi for you reply.

142input-way

Posted: Sat Sep 24, 2005 7:15 pm
by SRX
I saw fix mistake post
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?

Posted: Sat Oct 08, 2005 2:11 pm
by s000015
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?

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.....

Posted: Tue Dec 20, 2005 6:29 am
by lovemagic
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.

Posted: Sun Dec 25, 2005 5:58 am
by chunyi81
Read the problem description again:

Code: Select all

Note that regions always overlap icons so that obscured icons need not be considered
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.

Posted: Sun Dec 25, 2005 6:43 am
by mf
I too got WA after rejudge, but my mistake was that I'd missed the word 'visible' from this sentence:
otherwise it selects the closest visible icon (or icons in the case of a tie).
My previously AC code printed all closest icons (visible or not), now it rightfully gets WA.

Posted: Sun Dec 25, 2005 11:50 am
by chunyi81
mf, what should be the output for this test case?

Code: Select all

I       170     102
R       22      19      170     102
M       200      200
#
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.)

Code: Select all

Cut after AC. Thanks for all the help.
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.

Posted: Sun Dec 25, 2005 1:17 pm
by mf
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
# 
Both my programs (old and new ACs) print a blank line.

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);

    }

}