Skip to content

Instantly share code, notes, and snippets.

@NonWhite
Created August 1, 2013 23:07
Show Gist options
  • Select an option

  • Save NonWhite/6136152 to your computer and use it in GitHub Desktop.

Select an option

Save NonWhite/6136152 to your computer and use it in GitHub Desktop.
uva 10171
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#define f( i , a , b ) for(int i = a ; i < b ; i++)
#define TAM 50
using namespace std ;
int m , n = 30 ;
int Y[ TAM ][ TAM ] ;
int M[ TAM ][ TAM ] ;
void init(){
f( i , 0 , n ) f( j , 0 , n ) ;
}
ii floyd(){
}
int main(){
char A[ 10 ] , D[ 10 ] , izq[ 10 ] , der[ 10 ] ;
int len ;
while( scanf("%d" , &m ) == 1 ){
if( m == 0 ) break ;
init() ;
f( i , 0 , m ){
scanf("%s%s%s%s%d" , A , D , izq , der , len ) ;
int x = izq[ 0 ] - 'A' ;
int y = der[ 0 ] - 'A' ;
if( A[ 0 ] == 'Y' ){
Y[ x ][ y ] = 1 ;
if( D[ 0 ] == 'B' ) Y[ y ][ x ] = 1 ;
}else{
M[ x ][ y ] = 1 ;
if( D[ 0 ] == 'B' ) M[ y ][ x ] = 1 ;
}
}
ii R = floyd() ;
if( R.first < 0 ) printf("You will never meet.\n" ) ;
else printf("%d %c\n" , R.first , R.second ) ;
}
return 0 ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment