CodeForces 782D Innokenty and a Football League
来源:互联网 发布:网络嗅探器5.5.0 编辑:程序博客网 时间:2024/06/07 01:26
CodeForces 782D Innokenty and a Football League
题目描述:
有
- 队伍名的前三个字母;
- 若这样与另一支球队的简称重复,则两支球队的简称都改成球队队伍名的前两个字母和地区名的第一个字母。
要求输出方案。
题解:
按题意搜索即可,实现上有一些小细节。
题目链接: vjudge 原网站
代码:
#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <climits>#include <algorithm>using namespace std;#define MAXN 1010static int N, tag[MAXN], vis[MAXN];static char name[MAXN][4], S1[100], S2[100];void dfs(int x){ if (vis[x]) return ; else vis[x] = 1; for (int y = 0; y < N; y++) if (tag[y] == 2 && name[x][0] == name[y][0] && name[x][1] == name[y][1] && name[x][3] == name[y][2]) tag[y] = 3, dfs(y);}int main(){ scanf("%d", &N); for (int i = 0; i < N; i++) scanf("%s%s", S1, S2), memcpy(name[i], S1, 3), name[i][3] = S2[0], tag[i] = 2; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (i != j && name[i][0] == name[j][0] && name[i][1] == name[j][1] && name[i][2] == name[j][2]) tag[i] = tag[j] = 3; for (int i = 0; i < N; i++) if (tag[i] == 3) dfs(i); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (i != j && name[i][0] == name[j][0] && name[i][1] == name[j][1] && name[i][tag[i]] == name[j][tag[j]]) return printf("NO\n"), 0; printf("YES\n"); for (int i = 0; i < N; i++) printf("%c%c%c\n", name[i][0], name[i][1], name[i][tag[i]]); return 0;}
提交记录(AC / Total = 1 / 1):
0 0
- codeforces D. Innokenty and a Football League
- 【codeforces 782D】 Innokenty and a Football League
- Codeforces 782D Innokenty and a Football League【贪心】
- CodeForces 782D Innokenty and a Football League
- Codeforces 780D-Innokenty and a Football League
- 【Codeforces 780 D Innokenty and a Football League 】+ 模拟 + 贪心
- CodeForces 780D Innokenty and a Football League【模拟+贪心】
- D. Innokenty and a Football League----map
- D. Innokenty and a Football League
- D.Innokenty and a football league
- codeforces 782D Innokenty and a Football League(2-SAT)
- Codeforces Round #403 D. Innokenty and a Football League(思维+模拟)
- Codeforce 403 D. Innokenty and a Football League
- codeforce D. Innokenty and a Football League 贪心,模拟
- Codeforce 780D Innokenty and a Football League (贪心+模拟)
- codeforces 781B. Innokenty and a Football League(贪心)
- CF 782D. Innokenty and a Football League 贪心,思维,模拟
- 【Codeforces Round #403】Codeforces 781B Innokenty and a Football League
- 怎么把pdf首页改为其他页面
- 面向对象学习
- Android超时控制方法及场景
- CSS hack一览
- 看视频自学Java泛型
- CodeForces 782D Innokenty and a Football League
- Sublime Text 3快速生成HTML5的头部信息
- RunLoop的总结
- 2017年网易有道内推编程题
- 二叉树的简单实现
- QDialog,QWidget实现圆角,圆弧边框
- 微信小程序之提高应用速度小技巧
- 小小代码
- GAN学习笔记(一)——初探GAN