Fraud Busters

Fraud Busters

链接:https://ac.nowcoder.com/acm/contest/7852/H 来源:牛客网

The number of cars in Default City that travel to the city center daily vastly exceeds the number of available parking spots. The City Council had decided to introduce parking fees to combat the problem of overspill parking on the city streets. Parking fees are enforced using an automated vehicle registration plate scanners that take a picture of the vehicle registration plate, recognize the sequence of digits and letters in the code on the plate, and check the code against a vehicle registration database to ensure that parking fees are dutifully paid or to automatically issue a fine to the vehicle owner otherwise.
As soon as parking fees were introduced, a parking fee fraud had appeared. Some vehicle owners had started to close one or several digits or letters on their vehicle registration plate with pieces of paper while they park, thus making it impossible for the current version of the automated scanner to recognize their vehicle’s registration code and to issue them a fine.
The Default City Council had instituted the Fraud Busters Initiative (FBI) to design a solution to prevent this kind of fraud. The overall approach that FBI had selected is to expand the number of vehicle features that scanners recognize (including features like vehicle type and color), as well as excluding from the list any vehicles that are detected to be elsewhere at this time. This information should help to identify the correct vehicle by narrowing down the search in the vehicle registration database.
You are working for FBI. Your colleagues had already written all the complex pieces of the recognition software that analyses various vehicle features and provides you with a list of registration codes that might potentially belong to a scanned car. Your task it to take this list and a recognized code from the license plate (which may be partially unrecognized) and find all the registration codes that match.

输入描述:
The first line of the input file contains 9 characters of the code as recognized by the scanner. Code that was recognized by the the scanner is represented as a sequence of 9 digits, uppercase English letters, and characters “*” (star). Star represents a digit or a letter that scanner could not recognize.
The second line of the input file contains a single integer number n (1 ≤ n ≤ 1000) — the number of vehicle registration codes from the vehicle registration database.
The following n lines contain the corresponding registration codes, one code per line. Vehicle registration codes are represented as a sequence of 9 digits and uppercase English letters. All codes on these n lines of the input file are different.

输出描述:
On the first line of the output file write a single integer k (0 ≤ k ≤ n) — the number of codes from the input file that match the code that was recognized by the scanner. The code from the scanner matches the code from the database if the characters on all the corresponding positions in the codes are equal or the character from the scanner code is “*”.
On the following k lines write the matching codes, one code per line, in the same order as they are given in the input file.

示例1
输入
A**1MP19*
4
A001MP199
E885EE098
A111MP199
KT7351TTB

输出
2
A001MP199
A111MP199

题意:给一个车牌,位置不用管,其他位置相等,即为输出字符串。
思路:模拟、比对非
号位置字符串即可。

#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
string ss[1005];
string sss[1005];
int main() 
{
	string s;
	cin>>s;
	int n;
	int cnt=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>ss[i];
	for(int i=0;i<n;i++)
	{
		int flag=0;
		for(int j=0;j<ss[i].size();j++)
		{
		//	cout<<"*"<<s[j]<<" "<<ss[i][j]<<endl;
			if(s[j]=='*')
				continue;
			else
			{
				if(s[j]!=ss[i][j])
				{
					flag=1;
					break;
				}
			}
		}
		if(flag==0)
			{
				sss[cnt]=ss[i];
				cnt++;
			}
	}
	cout<<cnt<<endl;
	for(int i=0;i<cnt;i++)
		cout<<sss[i]<<endl;
		
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值