#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<int> solution(int n, vector<string> words) {
vector<int> answer;
int flag = 0;
int turn = 0;
int turn_a = 0;
int turn_b = 0;
int num =0;
//중복성 체크
for(int i=0; i < words.size() -1 ; i++){
for(int j = i+1; j < words.size(); j++){
if(words[i] == words[j]){
turn_a = j;
break;
}
}
}
//겹치는지 확인
for(int i=1; i< words.size();i++){
string before = words[i-1];
string now = words[i];
int leng = before.length();
if(before[leng-1] != now[0]){
turn_b = i;
break;
}
}
if(turn_a!=0 && turn_b!=0){
if(turn_a > turn_b)
turn = turn_b;
else
turn = turn_a;
}
else{
if(turn_a > turn_b)
turn = turn_a;
else
turn = turn_b;
}
if(turn != 0){
num = turn % n + 1;
turn = turn / n + 1;
}
answer.push_back(num);
answer.push_back(turn);
return answer;
}
너무 케바케로 푼거같지만.....