cf623a
来源:互联网 发布:金和网络摄像头 编辑:程序博客网 时间:2024/06/06 01:05
这个题是比较复杂的了,主要是我一开始想如何判断他不能成,主要是因为这个我一开始想成组合数的了,诶,我一开始就该想明白不应该是组合数的,因为要输出方案,不可能是组合数,这个题主要是用a,c来判,是b的话一定是可以的,先构造一些,然后再用b来判断,最后看如果冲突的话就是no。
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){ int n,m; while(cin>>n>>m) { int str[550][550],cnt[550],ans[550]; memset(str,0,sizeof(str)); memset(cnt,0,sizeof(cnt)); memset(ans,0,sizeof(ans)); for(int i = 0; i < m; i++) { int u,v; cin>>u>>v; str[u][v] = str[v][u] = 1; cnt[u]++; cnt[v]++; } for(int i = 1; i <= n; i++) if(cnt[i] == n - 1) ans[i] = 1; for(int i = 1; i <= n; i++) if(ans[i] == 0) for(int j = i + 1; j <= n; j++) if(str[i][j] == 0) ans[j] = 2; bool flag = true; for(int i = 1; i <= n; i++) { for(int j = i + 1; j <= n; j++) { if((abs(ans[i] - ans[j]) == 2 && str[i][j]) || (abs(ans[i] - ans[j]) < 2 && !str[i][j])) { cout<<"No"<<endl; flag = false; break; } } if(!flag) break; } if(!flag) continue; cout<<"Yes"<<endl; for(int i = 1; i <= n; i++) printf("%c",ans[i] + 'a'); cout<<endl; } return 0;}
晚上和我哥哥吃饭,。,。,。上午扎成筛子,下午练车。和locus玩的倒是挺好。,明天还要手术。。。我身上毛病可真多。但愿有一天我能配上所有人。,,通选易经老师说我桃花旺哈~
0 0
- cf623a
- CF623A Graph and String(二分图染色)
- 使用亚马逊云服务平台aws 搭建 shadowsocks
- LVS配置命令理解1
- Linux中环境变量文件及配置
- 信号阻塞未达pending原理机制讲解
- SQL中Case的使用方法
- cf623a
- 信号未达代码讲解
- [POJ2752] Seek the Name,Seek the Fame
- 获取ios设备当前网络状态
- JavaScript基础
- Codeforces Round #304 (Div. 2)-E. Soldier and Traveling
- 《程序员的思维修炼 开发认知潜能的九堂课》(一)
- 支付宝用AR集五福,VR和MR怎么看?
- ORB-SLAM(1) --- 让程序飞起来