Codeforces Round #451 (Div. 2) C
来源:互联网 发布:网络维护培训 编辑:程序博客网 时间:2024/05/29 09:21
每个姓名的电话号码 暴力枚举
#include<iostream>#include<algorithm>#include<iomanip>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<cmath>#include<set>#include<queue>#include<stack>#include<map>#define PI acos(-1.0)#define in freopen("in.txt", "r", stdin)#define out freopen("out.txt", "w", stdout)#define kuaidian ios::sync_with_stdio(0);using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn = 2e5 + 7, maxd = 1e8;const ll mod = 1e9 + 7;const int INF = 0x7f7f7f7f;int T, n;map<string, vector<string> > mp;set<string> name;bool is_ok(string a, string b) { if(a.length() < b.length()) return false; int aa = a.length()-1, bb = b.length()-1; while(bb >= 0) { if(a[aa] != b[bb]) return false; aa--; bb--; } return true;}int main() { kuaidian; cin >> n; string s, t; int m; for(int i = 0; i < n; ++i) { cin >> s >> m; name.insert(s); for(int j = 0; j < m; ++j) { cin >> t; mp[s].push_back(t); } } set<string>::iterator it; int vis[21][1111], cnt = 0; memset(vis, 0, sizeof vis); for(it = name.begin(); it != name.end(); ++it) { for(int i = 0; i < mp[*it].size(); ++i ) { for(int j = i+1; j < mp[*it].size(); ++j) { if(vis[cnt][i] || vis[cnt][j]) continue; if(is_ok(mp[*it][i], mp[*it][j])) { vis[cnt][j] = 1; } else if(is_ok(mp[*it][j], mp[*it][i])) { vis[cnt][i] = 1; } } } cnt++; } cout << name.size() << endl; int pos = 0; for( it = name.begin(); it != name.end(); ++it) { cout << (*it) << " "; int num = 0; for(int i = 0; i < mp[*it].size(); ++i) { if(vis[pos][i] == 0) num++; } cout << num; for(int i = 0; i < mp[*it].size(); ++i ) { if(!vis[pos][i]) { cout << " " << mp[*it][i]; } } cout << endl; pos++; } return 0;}
阅读全文
0 0
- Codeforces Round #451 (Div. 2) C
- Codeforces Round #451 (Div. 2) C
- 【codeforces】Codeforces Round #370 (Div. 2) C
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2)
- Codeforces Round #451 (Div. 2) C. Phone Numbers
- Codeforces Round #451 (Div. 2) A-C题解
- Codeforces Round #105 (Div. 2) C
- Codeforces Round 134 div 2 C题
- Codeforces Round #137 (Div. 2), problem: (C)
- Codeforces Round #153 (Div. 2) C题
- Codeforces Round #158 (Div. 2) C题
- lodash源码分析之compact中的遍历
- android view事件分发
- [jzoj]3577. 【CEOI2011】Traffic(转化模型+Floodfill)
- Codeforces Round #451 (Div. 2) E
- Codeforces Round #451 (Div. 2) D
- Codeforces Round #451 (Div. 2) C
- 管理感悟:软件的特性
- Codeforces Round #451 (Div. 2) B
- Codeforces Round #451 (Div. 2) A
- Html Agility Pack (HAP) 应用入门
- 使用set
- [Linux驱动炼成记]02-用户空间控制GPIO
- Dubbo 监控中心的介绍与简易监控中心的安装
- 11.6