^^
Posted: Fri Feb 27, 2004 12:48 am
Thank you
strain my eyes.........................FULL SEARCHING^-^


And I got Accepted.printf("%3c", (char)(i + 49)); -> printf("%3d", i + 1);
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
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) ;
}
}
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("");
}
}
}
Code: Select all
Note that regions always overlap icons so that obscured icons need not be considered
My previously AC code printed all closest icons (visible or not), now it rightfully gets WA.otherwise it selects the closest visible icon (or icons in the case of a tie).
Code: Select all
I 170 102
R 22 19 170 102
M 200 200
#
Code: Select all
Cut after AC. Thanks for all the help.
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 #
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);
}
}