set_intersection() 的用法 codeforces 245G
来源:互联网 发布:ps软件怎么收费 编辑:程序博客网 时间:2024/05/29 13:52
#include<bits/stdc++.h>#define eps 1e-9#define ALL(x) x.begin(),x.end()#define INS(x) inserter(x,x.begin())#define FOR(i,j,k) for(int i=j;i<=k;i++)#define MAXN 1005#define MAXM 40005#define INF 0x3fffffffusing namespace std;typedef long long LL;int i,j,k,n,m,x,y,T,ans,big,cas,num,len,an,bn,ans_num,cur;bool flag;map <string,int> mp;vector <int> st[10002];int vis[10002];int tmp[10002];string a,b,rev[10002];int main(){ scanf("%d",&n); for (i=1;i<=n;i++) st[i].clear(); mp.clear(); memset(tmp,0,sizeof(tmp)); num=0; an=bn=0; ans_num=0; cur=0; ans=0; for (i=1;i<=n;i++) { cin>>a>>b; if (!mp.count(a)) { mp[a]=++num; rev[num]=a; an=num; }else an=mp[a]; if (!mp.count(b)) { mp[b]=++num; rev[num]=b; bn=num; }else bn=mp[b]; st[an].push_back(bn); st[bn].push_back(an); } for (i=1;i<=num;i++) { sort(st[i].begin(),st[i].end()); } printf("%d\n",num); for (i=1;i<=num;i++) { int pre=0; cur=0;ans=0;ans_num=0; memset(vis,0,sizeof(vis)); for (vector <int> ::iterator it=st[i].begin();it!=st[i].end();it++) { vis[*it]=1; } vis[i]=1; for (j=1;j<=num;j++) { if (vis[j]) continue; cur=set_intersection(st[i].begin(),st[i].end(),st[j].begin(),st[j].end(),tmp)-tmp; if (cur>ans_num) { ans_num=cur; ans=1; }else if (cur==ans_num) { ans++; } } cout<<rev[i]<<" "<<ans<<endl; } return 0;}
阅读全文
0 0
- set_intersection() 的用法 codeforces 245G
- set_intersection的用法
- set_intersection
- set_intersection
- %g的用法
- MySQL笔记-\g和\G的用法
- std::set_intersection
- set_union set_intersection
- Android中<xliff:g></xliff:g>的用法
- 正则表达式中/g的用法
- 正则表达式中/g的用法
- 正则表达式中/g的用法
- ORACLE 10 g的 merge into 用法
- 正则表达式中/g的用法
- oracle 10g 客户端的一些用法
- 正则表达式中/g的用法
- codeforces 234G Practice
- CodeForces 589G Hiring
- Old Calculator
- Android中MVP的使用
- Hibernate配置文件hibernate.hbm2ddl.auto参数说明
- BIM中IFC介绍
- 关于5357端口
- set_intersection() 的用法 codeforces 245G
- opencv--外接矩形(圆)
- 企业网站建设能带来的7大好处
- MyBatis学习
- JavaScript实现H5游戏断线自动重连的技术
- <Meta name="" Content=""> 标签
- HDU 3717 Rescue(二分+技巧性模拟)【详解】
- 最长不重复子串
- Could not find com.android.support.constraint:constraint-layout:1.0.2错误的解决