알고리즘

[알고리즘] 백준 9933 - 민균이의 비밀번호 (C++)

blueberrysoda 2024. 11. 11. 23:47

[문제 링크] : https://www.acmicpc.net/problem/9933

#include <iostream>
#include <unordered_map>
#include <algorithm>
using namespace std;

int N;
string S;
unordered_map <string, int> M;

int main(){	
    cin >> N;

    for(int i=0; i<N; i++){
        cin >> S;
        if(M[S] == 0){
            M[S]++;
        }
        else{
            cout << S.length() << " " << S[S.length() / 2] << "\n";
            return 0;
        }

        reverse(S.begin(), S.end());
        
        if(M[S] == 0){
            M[S]++;
        }
        else{
            cout << S.length() << " " << S[S.length() / 2] << "\n";
            return 0;
        }
    }

    return 0;
}