Last active
February 23, 2020 01:37
-
-
Save joonas-yoon/cbff39becc33b01bb8033f79ed53977f to your computer and use it in GitHub Desktop.
BOJ 5052 - 전화번호 목록 (정렬)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
int T, n, i; | |
cin >> T; | |
while(T--){ | |
cin >> n; | |
string s; | |
vector<string> v(n); | |
for(i=0; i < n; ++i) cin >> v[i]; | |
sort(v.begin(), v.end()); | |
bool answer = true; | |
for(i=0; i < n - 1; ++i){ | |
if(v[i] == v[i + 1].substr(0, v[i].length())){ | |
answer = false; | |
break; | |
} | |
} | |
cout << (consist ? "YES":"NO") <<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment