1 条题解
-
0
Guest
-
0
#include <bits/stdc++.h> using namespace std; string s; int n; string str[101]; bool cmp(string q, string b) { if(q.size() > b.size())swap(q,b); for(int i = 0 ;i <q.size();i++) { int x1 = s.find(q[i]); int x2 = s.find(b[i]); if(x1!=x2){ return x1 < x2; } } } int main() { cin >> s; cin >> n; for (int i = 1; i <= n; i++) { cin >> str[i]; for (int j = 0; j < str[i].size() - 1; j++) { if (s.find(str[i][j]) > s.find(str[i][j + 1])) { cout << "No"; return 0; } } } sort(str + 1, str + 1 + n, cmp); string ss = ""; for (int i = 1; i <= n; i++) { ss += str[i]; } for (int j = 0; j < ss.size() - 1; j++) { if (s.find(ss[j]) > s.find(ss[j + 1])) { cout << "No"; return 0; } } cout<<"Yes"; return 0; }
- 1
信息
- ID
- 8476
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 3
- 标签
- 递交数
- 30
- 已通过
- 6
- 上传者