题目链接:传送门

题面:

D. Gourmet choice

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review  — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the dishes are different, because Mr. Apple doesn't like to eat the same food. For each pair of dishes from different days he remembers exactly which was better, or that they were of the same quality. After this the gourmet evaluates each dish with a positive integer.

Once, during a revision of a restaurant of Celtic medieval cuisine named «Poisson», that serves chestnut soup with fir, warm soda bread, spicy lemon pie and other folk food, Mr. Apple was very pleasantly surprised the gourmet with its variety of menu, and hence ordered too much. Now he's confused about evaluating dishes.

The gourmet tasted a set of nn dishes on the first day and a set of mm dishes on the second day. He made a table aa of size n×mn×m, in which he described his impressions. If, according to the expert, dish ii from the first set was better than dish jj from the second set, then aijaij is equal to ">", in the opposite case aijaij is equal to "<". Dishes also may be equally good, in this case aijaij is "=".

Now Mr. Apple wants you to help him to evaluate every dish. Since Mr. Apple is very strict, he will evaluate the dishes so that the maximal number used is as small as possible. But Mr. Apple also is very fair, so he never evaluates the dishes so that it goes against his feelings. In other words, if aijaij is "<", then the number assigned to dish ii from the first set should be less than the number of dish jj from the second set, if aijaij is ">", then it should be greater, and finally if aijaij is "=", then the numbers should be the same.

Help Mr. Apple to evaluate each dish from both sets so that it is consistent with his feelings, or determine that this is impossible.

Input

The first line contains integers nn and mm (1≤n,m≤10001≤n,m≤1000) — the number of dishes in both days.

Each of the next nn lines contains a string of mm symbols. The jj-th symbol on ii-th line is aijaij. All strings consist only of "<", ">" and "=".

Output

The first line of output should contain "Yes", if it's possible to do a correct evaluation for all the dishes, or "No" otherwise.

If case an answer exist, on the second line print nn integers — evaluations of dishes from the first set, and on the third line print mmintegers — evaluations of dishes from the second set.

Examples

input

3 4
>>>>
>>>>
>>>>

output

Yes
2 2 2
1 1 1 1

input

3 3
>>>
<<<
>>>

output

Yes
3 1 3
2 2 2

input

3 2
==
=<
==

output

No

题意描述:

Mr. Apple是一名美食家,在一家餐厅吃了两套菜,第一套n个菜,第二套m个菜,给这些菜评了分,现在给你n*m的矩阵,由'>','<'和'='构成。s[i][j]表示第一套菜的第i个菜跟第二套菜的第j个菜相比较的结果。要你求出这些菜的评分,最大的评分越小越好。

题面分析:

因为这道题目要求最大评分最小,那么,我们先假定比较相差都是一分和零分,把分数比这个位置好的或等于的边都存进来,价值分别为1和0,然后暴力dfs就行了,具体操作开代码。

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2005;
vector<int>Q[maxn];  //存放评分比i好或等于的边
vector<int>M[maxn];  //跟Q先对应,好就是1,等于就是0
int n, m;
int vis[maxn], dis[maxn];
char s[maxn];
void dfs(int u){vis[u] = 1;   //用来判断冲突情况for(int i=0;i<Q[u].size();++i){int v = Q[u][i], val = M[u][i];if(dis[v] < dis[u]+val){     //dis[v]应该等于dis[u]+val的,如果小于,重新赋值if(vis[v]){     //不能放外面,因为可能有等于的情况cout << "No" << endl; exit(0);}dis[v] = dis[u] + val;dfs(v);}}vis[u] = 0;
}
int main(){cin >> n >> m;for(int i=0;i<n;++i){scanf("%s", s);for(int j=0;j<m;++j){if(s[j] == '='){   //上面已经说明Q[i].push_back(j+n); M[i].push_back(0);Q[j+n].push_back(i); M[j+n].push_back(0);}else if(s[j] == '>'){Q[j+n].push_back(i); M[j+n].push_back(1);}else {Q[i].push_back(j+n); M[i].push_back(1);}}}for(int i=0;i<n+m;++i) dfs(i);  //要找到最低分开始dfs,所以要循环一遍cout << "Yes" << endl;for(int i=0;i<n-1;++i) printf("%d ", dis[i]+1); printf("%d\n", dis[n-1]+1);for(int j=n;j<n+m-1;++j) printf("%d ", dis[j]+1); printf("%d\n", dis[n+m-1]+1);return 0;
}

Codeforces 1131D - Gourmet choice相关推荐

  1. coderfoces D. Gourmet choice

      D. Gourmet choice time limit per test 2 seconds memory limit per test 256 megabytes 题目链接: https:// ...

  2. codeforces-1131D Gourmet choice(拓扑排序)

    传送门:QAQ 题意:第一天有n道菜,第二天有m道菜,然后有n行,每i行的第j个代表第一天的第i个菜与第二天的第m个菜的关系(>,<,=). 让你这些菜的价值符合题目提出的要求,并且价值最 ...

  3. Codeforces Round #541 (Div. 2)

    Codeforces Round #541 (Div. 2) 题号 题目 知识点 A Sea Battle 思维 B Draw! 贪心模拟 C Birthday 思维 D Gourmet choice ...

  4. Codeforces2000分左右DP泛刷

    乱七八糟的DP题随便刷刷 文章目录 CF148E - Porcelain CF1131D - Gourmet choice CF629C - Famil Door and Brackets CF895 ...

  5. 【CodeForces - 589F】Gourmet and Banquet (贪心,思维,二分)

    题干: A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet ...

  6. Codeforces Round #552 (Div. 3) Editorial 1154C - Gourmet Cat

    链接:https://codeforces.com/contest/1154/problem/C 题意:一只旅行的小猫在特定的星期里吃特定的食物,一四七a,二六b,三五c,现在给三种食物的数量,问小猫 ...

  7. Educational Codeforces Round 13 E. Another Sith Tournament 状压dp

    E. Another Sith Tournament 题目连接: http://www.codeforces.com/contest/678/problem/E Description The rul ...

  8. 【21.37%】【codeforces 579D】Or Game

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. Codeforces Round #573 (Div. 2)(ABCD)

    Tokitsukaze and Enhancement CodeForces - 1191A Tokitsukaze is one of the characters in the game &quo ...

最新文章

  1. AI不会很快取代作家——但未来可能比你想象的更近
  2. 阿里巴巴年度技术总结:人工智能在搜索的应用和实践
  3. C语言3D矢量操作有关的功能(附完整源码)
  4. TempDB为什么要根据CPU数目来决定文件个数
  5. php web教程视频教程下载,Web全栈 PHP+React系列视频教程下载
  6. MongoDB入门系列(二):Insert、Update、Delete、Drop
  7. Java之正則表達式【使用语法】
  8. JavaScript 的这个难点,毁掉了多少程序员?
  9. 赠票福利 | 2018人工智能计算大会报名开启:算力爆燃,AI进化
  10. 目标检测相关概念:IOU,precision, recall, AP, mAP
  11. 排序算法入门之堆排序
  12. android 4.4新功能介绍(Kitkat)
  13. python:读写文件判断一行是否为空
  14. Win300英雄服务器不显示,win10系统玩不了300英雄的还原步骤
  15. android下载文件地址,安卓迅雷下载的文件在哪里迅雷下载文件存放位置-独木成林...
  16. Scrum团队: I-型人 vs T- 型人
  17. python matplotlib plt 画图总结
  18. 深入浅出Flask PIN
  19. java aria,ARIA 标签和关系
  20. minSdk(API 29) deviceSdk(API 127)

热门文章

  1. 微信小程序(1)——注册开发者账号、安装开发工具
  2. selenium 记录 performance日志
  3. Python图片修复项目 —— Bringing-Old-Photos-Back-to-Life
  4. not_in函数致错
  5. 求多个数的最大公约数和最小公倍数
  6. pytorch时空数据处理2——图像转文本/字幕Image-Captionning(一)
  7. 李岳恒:区块链商业模式全景分析
  8. Java Swing图书管理系统,界面漂亮、功能全,直接使用 窗体版本-400
  9. mac下chrome浏览器查看网络源代码,及请求头信息
  10. linux清除网络缓存命令,如何清空linux的DNS缓存