# Data classification processing

describe

In the information society, there are huge amounts of data that need analysis and processing, such as the analysis of ID number, QQ users, mobile phone numbers, bank accounts and other activities and records.

Collect and input big data and classification rules, and classify and output big data through big data classification processing program.

Please note that there are multiple sets of input use cases.

Data range: 1 < = R, I < = 100, the size of the entered integer meets 0 < = Val < = 2 ^ 31-1;

Enter Description:

A set of input integer sequences I and a set of regular Integer Sequences R. the first integer of I and R sequences is the number of sequences (the number does not include the first integer); The integer range is 0 ~ (2 ^ 31) - 1, and the number of sequences is unlimited

Output Description:

Take out R from R in turn, process I, and find I that meets the conditions:

The number corresponding to I integer needs to continuously contain the number corresponding to R. For example, if R is 23 and I is 231, then I includes R and the conditions are met.

In order of R from small to large:

(1) Output R first;

(2) Then output the number of I satisfying the condition;

(3) Then output the position index of I satisfying the condition in the I sequence (starting from 0);

(4) Finally, output I.

Additional conditions:

(1)R needs to be sorted from small to large. The same r only needs to output the I with small index and satisfying conditions, and the I with large index needs to be filtered out

(2) If there is no I satisfying the condition, the corresponding R will not be output

(3) Finally, record the number of subsequent Integer Sequences at the first integer position of the output sequence (excluding the "number" itself)

Sequence I: 15123456786453,46,7,5,36654534567455456786453123 (the first 15 indicates that there are 15 subsequent integers)

Sequence R: 5,6,3,6,3,0 (the first 5 indicates that there are 5 subsequent integers)

Output: 30, 3, 6, 0123, 3453, 7, 3, 9453456, 13453, 14123, 6, 7, 1456, 2786, 4, 46, 8665, 9453456, 11456, 12786

explain:

30 --- 30 integers follow

3 --- sort from small to large. The first R is 0, but there is no I that meets the conditions. 0 is not output, and the next R is 3

6 - there are 6 I's with 3

The original serial number of 0-123 is 0

123-123 contains 3 and meets the conditions

Example 1

Input:

15 123 456 786 453 46 7 5 3 665 453456 745 456 786 453 123 5 6 3 6 3 0

Output:

30 3 6 0 123 3 453 7 3 9 453456 13 453 14 123 6 7 1 456 2 786 4 46 8 665 9 453456 11 456 12 786

Using regular expressions:

#include<iostream> #include<vector> #include<regex> #include<string> #include<algorithm> using namespace std; bool match(int model,int goal){ string md=to_string(model); string gl=to_string(goal); regex pattern(".*"+gl+".*"); return regex_match(md,pattern); } int main(){ int n,m; while(cin>>n){ vector<int>I; vector<int>R; for(int i=0;i<n;++i){ int tmp; cin>>tmp; I.push_back(tmp); } cin>>m; for(int i=0;i<m;++i){ int tmp; cin>>tmp; R.push_back(tmp); } sort(R.begin(), R.end()); R.erase(unique(R.begin(), R.end()),R.end()); vector<int> output1; vector<pair<int, int>> output2; for(int i=0;i<R.size();++i){ int count=0; bool flag=true; for(int j=0;j<n;++j){ if(match(I[j], R[i]) && flag){ output1.push_back(R[i]); output2.push_back({j,I[j]}); count++; flag=false; } else if(match(I[j], R[i])){ count++; output2.push_back({j,I[j]}); } } if(count!=0) output1.push_back(count); } int number=output1.size()+2*output2.size(); cout<<number<<' '; int index=0; for(int i=0;i<output1.size();++i){ cout<<output1[i]<<' '<<output1[++i]<<' '; for(int j=0;j<output1[i];++j){ cout<<output2[index].first<<' '<<output2[index].second<<' '; index++; } } cout<<endl; } return 0; }