2.알고리즘/백준
백준 31775 글로벌 포닉스 python / c++
HeoBeomSung
2024. 4. 30. 09:29
문제 링크 : https://www.acmicpc.net/problem/31775
s1,s2,s3 = [line.strip() for line in sorted(open(0))]
print('GLOBAL' if s1[0]=='k'and s2[0]=='l'and s3[0]=='p' else 'PONIX')
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector<string> lines(3);
for (int i = 0; i < 3; ++i) {
getline(cin, lines[i]);
}
sort(lines.begin(), lines.end());
if (lines[0][0] == 'k' && lines[1][0] == 'l' && lines[2][0] == 'p') {
cout << "GLOBAL" << endl;
} else {
cout << "PONIX" << endl;
}
return 0;
}
세 줄의 입력을 받아 정렬하고 변수에 할당합니다.
그런 다음 각 줄의 첫 글자만 확인합니다.
세 줄의 첫 글자가 모두 일치하면 'GLOBAL'을 출력합니다. 아니면 'PONIX'를 출력합니다
반응형