Question: an ACM sub-program that has the same set of characters. It is correct. It outputs spaces more than the standard. It is a format error. Others are errors.
Analysis: string. Scanning from front to back. If the two characters are different, an error occurs if the current character of string a is not a space;
If it is a space, it will not be correct. filter the space and check the remaining part. If the remaining characters are the same, the format is incorrect;
Otherwise, it must be an error;
Note: Pay attention to the space at the end position. I think of the days when I developed my own OJ a few years ago.
#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;}
Ultraviolet A 11734-big number of teams will solve this