/// b.cpp
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[ ] = { { 1 ,0 } ,{ 1 ,1 } ,{ 0 ,1 } ,{ - 1 ,1 } ,{ - 1 ,0 } ,{ - 1 ,- 1 } ,{ 0 ,- 1 } ,{ 1 ,- 1 } } ;
# define fi cin
# define fo cout
# define mp make_pair
template < class T > T smin( T & a,T b) { if ( a > b) a = b; return a; }
template < class T > T smax( T & a,T b) { if ( a < b) a = b; return a; }
int main( void )
{
#ifdef CF
freopen ( "input" ,"r" ,stdin ) ;
#endif // CF
srand ( time ( 0 ) ) ;
fo << fixed << setprecision( 7 ) ;
cerr << fixed << setprecision( 7 ) ;
static int was[ 1 << 10 ] [ 1 << 10 ] ;
static char s[ 1 << 10 ] [ 1 << 10 ] ;
int n,m;
fi>> n>> m;
for ( int i = 1 ; i <= n; ++ i)
fi>> ( s[ i] + 1 ) ;
for ( int i = 1 ; i <= n; ++ i)
for ( int j = 1 ; j <= m; ++ j)
was[ i] [ j] + = was[ i - 1 ] [ j] + was[ i] [ j - 1 ] - was[ i - 1 ] [ j - 1 ] + ( s[ i] [ j] == '*' ) ;
auto get = [ & ] ( int x1,int y1,int x2,int y2)
{
int ans = was[ x2] [ y2] + was[ x1 - 1 ] [ y1 - 1 ] - was[ x1 - 1 ] [ y2] - was[ x2] [ y1 - 1 ] ;
return ans;
} ;
pii S,T;
for ( int i = 1 ; i <= n; ++ i)
for ( int j = 1 ; j <= m; ++ j)
{
if ( s[ i] [ j] == 'S' )
S = mp( i,j) ;
if ( s[ i] [ j] == 'T' )
T = mp( i,j) ;
}
const int dx[ ] = { 0 ,1 ,- 1 ,0 } ;
const int dy[ ] = { 1 ,0 ,0 ,- 1 } ;
for ( int a = 0 ; a < 4 ; ++ a)
for ( int b = 0 ; b < 4 ; ++ b)
for ( int i = 0 ; i <= 1000 ; ++ i)
for ( int j = 0 ; j <= 1000 ; ++ j)
{
int xx = S.x + i * dx[ a] ;
int yy = S.y + i * dy[ a] ;
if ( ! ( 1 <= xx && xx <= n) || ! ( 1 <= yy && yy <= m) || get( min( S.x ,xx) ,min( S.y ,yy) ,max( S.x ,xx) ,max( S.y ,yy) ) )
continue ;
int cx = xx;
int cy = yy;
xx + = j * dx[ b] ;
yy + = j * dy[ b] ;
if ( ! ( 1 <= xx && xx <= n) || ! ( 1 <= yy && yy <= m) || get( min( cx,xx) ,min( cy,yy) ,max( cx,xx) ,max( cy,yy) ) )
continue ;
if ( ! ( xx == T.x || T.y == yy) || get( min( xx,T.x ) ,min( yy,T.y ) ,max( xx,T.x ) ,max( yy,T.y ) ) )
continue ;
return yes * 0 ;
}
no;
cerr << "Time elapsed :" << clock ( ) * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n ' ;
return 0 ;
}
Ly8vIGIuY3BwCgojIGluY2x1ZGUgPHN0ZGlvLmg+CiMgaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgcGFpciA8IGludCAsIGludCA+IEREW10gPSB7ezEsMH0sezEsMX0sezAsMX0sey0xLDF9LHstMSwwfSx7LTEsLTF9LHswLC0xfSx7MSwtMX19OwojIGRlZmluZSBmaSBjaW4KIyBkZWZpbmUgZm8gY291dAojIGRlZmluZSBtcCBtYWtlX3BhaXIKdGVtcGxhdGUgPCBjbGFzcyBUID4gVCBzbWluKFQgJmEsVCBiKSB7aWYgKGEgPiBiKSBhID0gYjtyZXR1cm4gYTt9CnRlbXBsYXRlIDwgY2xhc3MgVCA+IFQgc21heChUICZhLFQgYikge2lmIChhIDwgYikgYSA9IGI7cmV0dXJuIGE7fQppbnQgbWFpbih2b2lkKQp7CiAgICAjaWZkZWYgQ0YKICAgIGZyZW9wZW4oImlucHV0IiwiciIsc3RkaW4pOwogICAgI2VuZGlmIC8vIENGCiAgICBzcmFuZCh0aW1lKDApKTsKICAgIGZvIDw8IGZpeGVkIDw8IHNldHByZWNpc2lvbig3KTsKICAgIGNlcnIgPDwgZml4ZWQgPDwgc2V0cHJlY2lzaW9uKDcpOwogICAgc3RhdGljIGludCB3YXNbMSA8PCAxMF1bMSA8PCAxMF07CiAgICBzdGF0aWMgY2hhciBzWzEgPDwgMTBdWzEgPDwgMTBdOwogICAgaW50IG4sbTsKICAgIGZpPj5uPj5tOwogICAgZm9yIChpbnQgaSA9IDE7aSA8PSBuOysraSkKICAgICAgICBmaT4+KHNbaV0gKyAxKTsKICAgIGZvciAoaW50IGkgPSAxO2kgPD0gbjsrK2kpCiAgICAgICAgZm9yIChpbnQgaiA9IDE7aiA8PSBtOysraikKICAgICAgICAgICAgd2FzW2ldW2pdICs9IHdhc1tpIC0gMV1bal0gKyB3YXNbaV1baiAtIDFdIC0gd2FzW2kgLSAxXVtqIC0gMV0gKyAoc1tpXVtqXSA9PSAnKicpOwogICAgYXV0byBnZXQgPSBbJl0oaW50IHgxLGludCB5MSxpbnQgeDIsaW50IHkyKQogICAgewogICAgICAgIGludCBhbnMgPSB3YXNbeDJdW3kyXSArIHdhc1t4MSAtIDFdW3kxIC0gMV0gLSB3YXNbeDEgLSAxXVt5Ml0gLSB3YXNbeDJdW3kxIC0gMV07CiAgICAgICAgcmV0dXJuIGFuczsKICAgIH07CiAgICBwaWkgUyxUOwogICAgZm9yIChpbnQgaSA9IDE7aSA8PSBuOysraSkKICAgICAgICBmb3IgKGludCBqID0gMTtqIDw9IG07KytqKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKHNbaV1bal0gPT0gJ1MnKQogICAgICAgICAgICAgICAgUyA9IG1wKGksaik7CiAgICAgICAgICAgIGlmIChzW2ldW2pdID09ICdUJykKICAgICAgICAgICAgICAgIFQgPSBtcChpLGopOwogICAgICAgIH0KICAgIGNvbnN0IGludCBkeFtdID0gezAsMSwtMSwwfTsKICAgIGNvbnN0IGludCBkeVtdID0gezEsMCwwLC0xfTsKICAgIGZvciAoaW50IGEgPSAwO2EgPCA0OysrYSkKICAgICAgICBmb3IgKGludCBiID0gMDtiIDwgNDsrK2IpCiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwO2kgPD0gMTAwMDsrK2kpCiAgICAgICAgICAgICAgICBmb3IgKGludCBqID0gMDtqIDw9IDEwMDA7KytqKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGludCB4eCA9IFMueCArIGkgKiBkeFthXTsKICAgICAgICAgICAgICAgICAgICBpbnQgeXkgPSBTLnkgKyBpICogZHlbYV07CiAgICAgICAgICAgICAgICAgICAgaWYgKCEoMSA8PSB4eCAmJiB4eCA8PSBuKSB8fCAhKDEgPD0geXkgJiYgeXkgPD0gbSkgfHwgZ2V0KG1pbihTLngseHgpLG1pbihTLnkseXkpLG1heChTLngseHgpLG1heChTLnkseXkpKSkKICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgaW50IGN4ID0geHg7CiAgICAgICAgICAgICAgICAgICAgaW50IGN5ID0geXk7CiAgICAgICAgICAgICAgICAgICAgeHggKz0gaiAqIGR4W2JdOwogICAgICAgICAgICAgICAgICAgIHl5ICs9IGogKiBkeVtiXTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgxIDw9IHh4ICYmIHh4IDw9IG4pIHx8ICEoMSA8PSB5eSAmJiB5eSA8PSBtKSB8fCBnZXQobWluKGN4LHh4KSxtaW4oY3kseXkpLG1heChjeCx4eCksbWF4KGN5LHl5KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgIGlmICghKHh4ID09IFQueCB8fCBULnkgPT0geXkpIHx8IGdldChtaW4oeHgsVC54KSxtaW4oeXksVC55KSxtYXgoeHgsVC54KSxtYXgoeXksVC55KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB5ZXMgKiAwOwogICAgICAgICAgICAgICAgfQogICAgbm87CiAgICBjZXJyIDw8ICJUaW1lIGVsYXBzZWQgOiIgPDwgY2xvY2soKSAqIDEwMDAuMCAvIENMT0NLU19QRVJfU0VDIDw8ICIgbXMiIDw8ICdcbic7CiAgICByZXR1cm4gMDsKfQ==
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:34:5: error: ‘pii’ was not declared in this scope
pii S,T;
^~~
prog.cpp:39:17: error: ‘S’ was not declared in this scope
S = mp(i,j);
^
prog.cpp:41:17: error: ‘T’ was not declared in this scope
T = mp(i,j);
^
prog.cpp:50:30: error: ‘S’ was not declared in this scope
int xx = S.x + i * dx[a];
^
prog.cpp:60:33: error: ‘T’ was not declared in this scope
if (!(xx == T.x || T.y == yy) || get(min(xx,T.x),min(yy,T.y),max(xx,T.x),max(yy,T.y)))
^
prog.cpp:62:28: error: ‘yes’ was not declared in this scope
return yes * 0;
^~~
prog.cpp:64:5: error: ‘no’ was not declared in this scope
no;
^~
stdout