#include #include // strcmpを使うために必要 int main(void){ int N; char A[100][100][31]; int count[100] = {0}; char target[9] = "nyanpass"; // printf("%s\n",target); // check ok scanf("%d",&N); for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ scanf("%s",A[i][j]); if(strcmp(target,A[i][j])==0){ count[j] += 1; } } } // check ok /* for(int k = 0; k < N; k++){ printf("%d ",count[k]); } printf("\n"); */ for(int k = 0; k < N; k++){ if(count[k] == (N-1)){ // 1人候補を見つけたらそれ例外にいないか探す for(int l = k+1; l < N; l++){ if((count[k] == count[l])&&(k != l)){ // 2人いたらダメ printf("-1\n"); return 0; } } // 1人しかいない為、配列番号+1を出力 printf("%d\n",k+1); return 0; } } printf("-1\n"); return 0; }