Created
January 10, 2017 10:39
-
-
Save dohatsutsu/d95be5829bd9668276e44ff2dd6a5505 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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