标签:
Description
Input
Output
Sample Input
Sample Output
#include <stdio.h> #include <string> #include <iostream> #include <algorithm> using namespace std; string s[10010]; bool judge(int n) { int len, i, j; for(i = 0; i < n-1; i++) { len = s[i].size(); //printf("\n%d\n", len); for(j = 0; j < len; j++) { if(s[i][j] != s[i+1][j]) { // cout << s[i][j] << ‘ ‘ << s[i+1][j]; break; } } //printf("\n%d\n", j); if(j == len) return true; } return false; } int main() { int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); for(int i = 0; i < n; i++) cin >> s[i]; sort(s, s+n); //for(int i = 0; i < n; i++) // cout << s[i] << " "; if(judge(n)) printf("NO\n"); else printf("YES\n"); } return 0; }
E - Phone List(字典序,string类型使用)
标签:
原文地址:http://www.cnblogs.com/rain-1/p/4797861.html