Skip to content

Instantly share code, notes, and snippets.

@dohatsutsu
Created January 10, 2017 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dohatsutsu/d95be5829bd9668276e44ff2dd6a5505 to your computer and use it in GitHub Desktop.
Save dohatsutsu/d95be5829bd9668276e44ff2dd6a5505 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int N,cc,t[2];
bool visited[1005];
char a[1005][1005];
void dfs(int pos){
if(visited[pos])return;
visited[pos]=true;
cc++;
for(int i=0;i<N;i++)
if(a[pos][i]=='Y')
dfs(i);
}
int main(){
scanf("%d",&N);
int total=N*(N-1)/2;
for(int i=0;i<N;i++){
scanf("%s",a[i]);
for(int j=0;j<i;j++)
if(a[i][j]=='Y')total--;
}
for(int i=0;i<N;i++){
if(visited[i])continue;
cc=0;
dfs(i);
t[cc%2]++;
}
int f=(t[0]==0&&t[1]==2?0:1);
if( (t[0]==1&&t[1]==2) || total%2==f )cout<<"Taro"<<endl;
else cout<<"Hanako"<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment