자라는 개발자/문제풀이

백준 c++ 9933 민균이의 비밀번호

자란다 2022. 8. 8. 18:28
728x90
반응형

9933 민균이의 비밀번호


문제풀이

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void fast_io(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int t;
vector<string> v;
vector<string> rv;
int main()
{
    fast_io();
    cin >> t;
    for(int i=0;i<t;i++)
    {
        string tmp;
        cin >> tmp;
        v.push_back(tmp);
        reverse(tmp.begin(),tmp.end());
        rv.push_back(tmp);
    }
    for(int i=0;i<t;i++)
    {
        for(int j=0;j<t;j++)
            if(!v[i].compare(rv[j]))
            {
                int len = v[i].length();
                cout << len << " " << v[i][len/2];
                return 0;   
            }
    }        
}       

받은 값을 반전시켜준뒤 각각 넣어놓고 값을 비교해주었다.

728x90
반응형

'자라는 개발자 > 문제풀이' 카테고리의 다른 글

백준 c++ 19709 LunchBox  (0) 2022.08.16
백준 c++ 11728 배열 합치기  (0) 2022.08.15
백준 c++ 11645 I've Been Everywhere, Man  (0) 2022.07.23
백준 c++ 15577 Prosjek  (0) 2022.07.20
백준 c++ 21194 Meditation  (0) 2022.07.11