Ultraviolet A 11734-big number of teams will solve this

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.