首页 > 代码库 > UVa 11734 - Big Number of Teams will Solve This
UVa 11734 - Big Number of Teams will Solve This
题目:一个ACM的判题的小程序,两组字符全相同,为正确,比标准多输出空格,为格式错误,其他为错误。
分析:字符串。从前向后扫描,如果两字符不同,若A串当前字符不是空格,则错误;
若是空格,则一定不会是正确,滤过空格,看剩余部分,如果剩下字符相同则格式错误;
否则,一定错误;
说明:注意结束位置的空格。想起几年前开发自己OJ的日子了。
#include <iostream> #include <cstdlib> #include <string> #include <cstdio> using namespace std; string s,t; int main() { int n; while (cin >> n) { while (getchar()!= '\n'); for (int k = 1 ; k <= n ; ++ k) { getline(cin, t); getline(cin, s); int move = 0,flag = 0; for (int i = 0 ; i < s.length() ; ++ i) { while (move < t.length() && s[i] != t[move] && t[move] == ' ') { flag = 2; move ++; } if (s[i] != t[move]) { flag = 1; break; }else move ++; } while (move < t.length() && t[move] == ' ') { flag = 2; move ++; } cout << "Case " << k << ": "; if (flag == 1 || move < t.length()) cout << "Wrong Answer" << endl; else if (flag == 2) cout << "Output Format Error" << endl; else cout << "Yes" << endl; } } return 0; }
UVa 11734 - Big Number of Teams will Solve This
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。