2019 meter sixth preliminary road garlic

A.

https://nanti.jisuanke.com/t/39455

VIPKID is the world's fastest growing online youth children's English education brand, pure North American teacher  1 1 pair  1 1 online delivery, the Chinese children to connect with teachers in North America by way of the Internet. VIPKID To help each child find the most suited to their foreign teachers, foreign teachers have language skills in the teaching of multi-layered dimensions delineated hundreds of labels, combined with intelligent algorithms to match the teachers and students, which is the most appropriate recommendation to the participants I am a teacher.

VIPKID to intelligently match the students and teachers through big data and labels. When we label abstracted into brackets (), the matching process is simplified to match a string of brackets, I hope you clever to solve the following problem: to determine whether a given sequence parentheses legitimate and anti-palindrome.

For this sequence tag brackets abstract composition, we have the following definitions:

Legal parentheses sequence:

  • Empty sequence;
  • If A A, B B is legal brackets sequence, then (A) ( A ) and AB A B bracketed sequence are legitimate;

Anti palindromic sequence parentheses: if the sequence length is  L L, and characters from  0 zero number, then any of  S [I] S [ I ] and  S [-of Li. 1] S [ of Li - . 1 ] corresponding to character should be different. ( I  in the range of  0 ≤ ≤ L - . 1  )

Input Format

A string line  S S.

Output Format

If it is legitimate and anti-palindrome string, output "YES", otherwise a "NO". (All without double quotes)

Scale data

S S length is less than 10 ^ 1e6 .

Sample input 1

()()()

Sample output 1

YES

Sample input 2

()(())

Sample output 2

NO 
meaning of problems: determining matching brackets + trans palindromic
 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     ios::sync_with_stdio(0);
 8     cin.tie(0);
 9     cout.tie(0);
10 
11     string str;
12     bool kuohao,fanhuiwen;
13     stack<char> sc;
14     //while(cin>>str){
15     cin>>str;
16         kuohao=true;
17         fanhuiwen=true;
18         char tmp;
19         for(int i=0;i<str.size();i++){
20             if(str[i]=='('){
21                 sc.push(str[i]);
22             }else if(str[i]==')'){
23                 if(sc.empty()){
24                     kuohao=false;
25                     break;
26                 }else{
27                     tmp=sc.top(); sc.pop();
28                     if(tmp=='('){
29                         continue;
30                     }else{
31                         kuohao=false;
32                         break;
33                     }
34 
35                 }
36             }
37         }
38         if(!sc.empty()) kuohao=false;
39 
40         int strlen=str.size();
41         for(int i=0;i<=strlen/2;i++){
42             if(str[i]==str[strlen-i-1]){
43                 fanhuiwen=false;
44                 break;
45             }
46         }
47         if(kuohao&&fanhuiwen){
48             cout<<"YES"<<endl;
49         }else{
50             cout<<"NO"<<endl;
51         }
52     //}
53     return 0;
54 }
View Code

 

BC.

https://nanti.jisuanke.com/t/39457

Sample input

3
1 3 5
0 1 2
5
1 2 3 4 5

Sample Output

0 1 1 2 2

The meaning of problems: violence according to the formula, pay attention to long long.

 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 long long a[1000005],b[1000005],q[1000005];
 6 long long resu[1000005];
 7 
 8 int main()
 9 {
10     ios::sync_with_stdio(0);
11     cin.tie(0);
12     cout.tie(0);
13 
14     int n,Q;
15     cin>>n;
16     for(int i=0;i<n;i++){
17         cin>>a[i];
18     }
19     for(int i=0;i<n;i++){
20         cin>>b[i];
21     }
22     cin>>Q;
23     for(int i=0;i<Q;i++){
24         cin>>q[i];
25     }
26     long long minn=1e19;
27     for(int i=0;i<Q;i++){
28         minn=1e19;
29         long long tmp=0;
30         for(int j=0;j<n;j++){
31             long long chengji=(q[i]-a[j]);
32             tmp=chengji*chengji+b[j];
33             minn=min(minn,tmp);
34         }
35         resu[i]=minn;
36     }
37     for(int i=0;i<Q;i++){
38         cout<<resu[i]<<" ";
39     }
40     return 0;
41 }
View Code

D:未做

 

Guess you like

Origin www.cnblogs.com/TWS-YIFEI/p/10993351.html