题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5099
卡读题,实际上题目中表述的题意并不完整,所以要认真读并且加上一些现实的“常识”
关于枚举题意,感觉应该三个人分别看,然后讨论出最有可能的题意是什么
为了避免wa后心态的变化,在尽量保证不敲歪的前提下,在交之前就应该把所有可能的题意都想好,列出来,按可能性排序,再交
感觉只有做到了上面这些才能够wa后不慌
关于“第一个输出要判断前两个字母还是只判断第一个字母就好的问题”
注意到对于第一个字母,题意的描述是:
“The code names are ordered alphabetically. The latest code name is K (KitKat).”
对于最后一个字母,题意的描述是:
“sequentially starting with A;”
然而对于第二个字母,文中并没有描述字母间的大小关系
所以推出很可能只需判断第一个字母
关于“第二个输出中,‘the same code branch"是要判前两个字母还是第一个字母就好的问题
我是根据现实中,一般是family中的同个branch才有相互比较的必要,推测应该是要判两个字母
主要是上面两个地方难懂
实在不行就只能枚举题意了
#include <cstring> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <iostream> #include <cstdio> #include <stack> #include <vector> #include <queue> #include <map> #include <set>using namespace std;const int maxn = 20;char a[maxn], b[maxn]; const char ch[] = "<=>";int main() {//freopen("in.txt", "r", stdin);int T;scanf("%d", &T);int kase = 0;while(T--){printf("Case %d:", ++kase);scanf("%s%s", a, b);int ans1;if(a[0] < b[0])ans1 = -1;else if(a[0] > b[0])ans1 = 1;elseans1 = 0;int ans2 = 0;for(int i = 2; i <= 4 && ans2 == 0; i++){if(a[i] < b[i])ans2 = -1;else if(a[i] > b[i])ans2 = 1;}bool flag;if(ans1 == 0 && a[1] == b[1])flag = true;elseflag = false;if(flag){if(ans2 == 0){if(a[5] < b[5])ans2 = -1;else if(a[5] > b[5])ans2 = 1;elseans2 = 0;}}printf(" %c", ch[ans1+1]);printf(" %c", ch[ans2+1]);printf("\n");}return 0; }