今天下午有一个儿童节热身的训练比赛,我跟一个同学两个人组队尝试做了一下,我们真的好菜,就A了三个题,看其他同学组的队都做了五六个(当然学长们组的队做了十个。。。)(记得我们提交完第二个题目之前学长们已经A了三道了。)
起初我们做第一道时(A题)还比较顺利,到了第二道(G题)就有点稳不住了(总是显示提交失败,提交好多次都提交不上,大概是需要排好长的队。)第三道题目(D题)看了很久,一直在分析,到最后提交时显示越界,看思路没有问题,一直找不到错误,最后发现输入时没有使用字符数组,只是用的字符串(当数据量过大时,字符串会爆)(虽然定义了字符数组,但是改正之前输入时误用字符串输入的。)
在比赛时还有一些小问题:就是我们是在教室里写的代码,用的笔记本,当一台电脑没电时换用电脑时交接没有顺畅,我记得提交第二题时,忘了换号,上面还是个人的VJ号,没有提交成功就立刻退掉了,换用了小队的账号,导致在Rank中还显示了个人账号AC率为零的提交记录,尴尬。。。

下面说一下具体题目:
A - A CodeForces - 1167A
A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not.

You are given a string ss of length nn, consisting of digits.

In one operation you can delete any character from string ss. For example, it is possible to obtain strings 112, 111 or 121 from string 1121.

You need to determine whether there is such a sequence of operations (possibly empty), after which the string ss becomes a telephone number.

Input
The first line contains one integer tt (1≤t≤1001≤t≤100) — the number of test cases.

The first line of each test case contains one integer nn (1≤n≤1001≤n≤100) — the length of string ss.

The second line of each test case contains the string ss (|s|=n|s|=n) consisting of digits.

Output
For each test print one line.

If there is a sequence of operations, after which ss becomes a telephone number, print YES.

Otherwise, print NO.

Example
Input

2
13
7818005553535
11
31415926535

Output

YES
NO

这道题目就是类似于输入正确的手机号,且首位为‘8’,当然手机号要求为11位(当输入的数字位数大于11位时看能否通过删除手机号位数来获得正确的手机号码)。
这个题相对来说很简单,我们可以写两个判断,当输入手机号位数小于11时直接输出“NO”;当输入手机号位数大于11时,我们可以用输入的数字位数-10,然后判断从首位到该总数字位数-10中是否存在字符‘8’,如果存在我们便可以通过删除字符获得正确的手机号(‘8’+后面十位数字,其余全部可直接删掉。)

#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int  test(int b,string a)
{
    for(int i=0;i<b-10;i++)
    {
        if(a[i]=='8') return 1;
    }
    return 0;
}
int main()
{
    string a;
    int n,l;
    cin>>n;
    while(n--)
    {
        cin>>l;
        cin>>a;
        if(l<11) {cout<<"NO"<<endl;continue;}
        if(test(l,a)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

G - G CodeForces - 1165B
Polycarp wants to train before another programming competition. During the first day of his training he should solve exactly 11 problem, during the second day — exactly 22 problems, during the third day — exactly 33 problems, and so on. During the kk-th day he should solve kk problems.

Polycarp has a list of nn contests, the ii-th contest consists of aiai problems. During each day Polycarp has to choose exactly one of the contests he didn’t solve yet and solve it. He solves exactly kk problems from this contest. Other problems are discarded from it. If there are no contests consisting of at least kk problems that Polycarp didn’t solve yet during the kk-th day, then Polycarp stops his training.

How many days Polycarp can train if he chooses the contests optimally?

Input
The first line of the input contains one integer nn (1≤n≤2⋅1051≤n≤2⋅105) — the number of contests.

The second line of the input contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤2⋅1051≤ai≤2⋅105) — the number of problems in the ii-th contest.

Output
Print one integer — the maximum number of days Polycarp can train if he chooses the contests optimally.

Examples

Input

    4
    3 1 4 1

Output

    3

Input

    3
    1 1 1

Output

    1

Input

    5

    1 1 1 2 2

Output

    2

这是一道给出一组给出数据判断是否大于已知数据值的问题(具体我忘了是哪个了,很相似。)已知数据为1-k;我们可以对给出的数据进行排序,当给出的数据大于每一天必须要完成的量时,计数值加一,效率为o(n);
具体还是看一下代码:

#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int a[200001]={0};
int main()
{
    int n,tmp=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]>=tmp+1) tmp++;
    }
    cout<<tmp<<endl;
   return 0;
}

D - D CodeForces - 1167D
A string is called bracket sequence if it does not contain any characters other than “(” and “)”. A bracket sequence is called regular (shortly, RBS) if it is possible to obtain correct arithmetic expression by inserting characters “+” and “1” into this sequence. For example, “”, “(())” and “()()” are RBS and “)(” and “(()” are not.

We can see that each opening bracket in RBS is paired with some closing bracket, and, using this fact, we can define nesting depth of the RBS as maximum number of bracket pairs, such that the 2-nd pair lies inside the 1-st one, the 3-rd one — inside the 2-nd one and so on. For example, nesting depth of “” is 0, “()()()” is 1 and “()((())())” is 3.

Now, you are given RBS ss of even length nn. You should color each bracket of ss into one of two colors: red or blue. Bracket sequence rr, consisting only of red brackets, should be RBS, and bracket sequence, consisting only of blue brackets bb, should be RBS. Any of them can be empty. You are not allowed to reorder characters in ss, rr or bb. No brackets can be left uncolored.

Among all possible variants you should choose one that minimizes maximum of rr’s and bb’s nesting depth. If there are multiple solutions you can print any of them.

Input
The first line contains an even integer nn (2≤n≤2⋅1052≤n≤2⋅105) — the length of RBS ss.

The second line contains regular bracket sequence ss (|s|=n|s|=n, si∈{si∈{"(", “)”}}).

Output
Print single string tt of length nn consisting of “0”-s and “1”-s. If titi is equal to 0 then character sisi belongs to RBS rr, otherwise sisi belongs to bb.

Examples

Input
2
()
Output
11
Input
4
(())
Output
0101
Input
10
((()())())
Output
0110001111

Note
In the first example one of optimal solutions is s=s= “()()”. rr is empty and b=b= “()()”. The answer is max(0,1)=1max(0,1)=1.

In the second example it’s optimal to make s=s= “(())(())”. r=b=r=b= “()()” and the answer is 1.

In the third example we can make s=s= “((()())())((()())())”. r=r= “()()()()” and b=b= “(()())(()())” and the answer is 2.

大体题意是给出一组括号(已经相互配对),然后将这组括号涂成红与蓝两种颜色(必须所有的都涂),求涂完之后在嵌套中红或蓝最小花费的最大值。(具体可见提示,我的描述似乎存在问题。。。)当然输出时并非输出该最值,只是输出满足条件的红或蓝的其中一种涂法(代码中采用红1蓝0的方式来表示涂色方案)
思路是这样的:我们可以在红与蓝涂色相同的情况下先涂红色,然后涂蓝色,当左括号出现时无论是红还是蓝其中一个涂色的要加一,反之当右括号出现时涂色的计数要减一。另外我们用另外一组数组来记录0或1的存储情况。(其实可以直接输出)具体演示请参考代码:

#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
char a[200001];
int d[200001]={0};
int main()
{
    int n,b=0,c=0;
    cin>>n;
    int  count=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]=='('&&b==c) {d[i]=1;b++;continue;}
        if(a[i]=='('&&c<b) {d[i]=0;c++;continue;}
        if(a[i]==')'&&b>c) {d[i]=1;b--;continue;}
        if(a[i]==')'&&b==c) {d[i]=0;c--;}
    }
    for(int i=0;i<n;i++)
    {
        cout<<d[i];
    }
    return 0;
}

做的这几个题目都是水题,还有的题目没有学过,比如一个并查集的题:

C - C CodeForces - 1167C
In some social network, there are nn users communicating with each other in mm groups of friends. Let’s analyze the process of distributing some news between users.

Initially, some user xx receives the news from some source. Then he or she sends the news to his or her friends (two users are friends if there is at least one group such that both of them belong to this group). Friends continue sending the news to their friends, and so on. The process ends when there is no pair of friends such that one of them knows the news, and another one doesn’t know.

For each user xx you have to determine what is the number of users that will know the news if initially only user xx starts distributing it.

Input
The first line contains two integers nn and mm (1≤n,m≤5⋅1051≤n,m≤5⋅105) — the number of users and the number of groups of friends, respectively.

Then mm lines follow, each describing a group of friends. The ii-th line begins with integer kiki (0≤ki≤n0≤ki≤n) — the number of users in the ii-th group. Then kiki distinct integers follow, denoting the users belonging to the ii-th group.

It is guaranteed that ∑i=1mki≤5⋅105∑i=1mki≤5⋅105.

Output
Print nn integers. The ii-th integer should be equal to the number of users that will know the news if user ii starts distributing it.

Example
Input

7 5
3 2 5 4
0
2 1 2
1 1
2 6 7

Output

4 4 1 4 4 2 2 

这道题其实我们觉得是树的题目,用树的方式解决应该是可以的。另外的思路是一维数组遍历,通过计数来相减求和来解决,但是这样的话会超时的。。。然后用结构体数组也是一样。也想到了vector存储然后使用find函数查找或者使用set排序然后查找等思路,但是这样最后总会超时。

总之这次做的几个题都很水,最后的一个小时内又做了一道题目,但是也没有做出来。不过这次训练也学到了不少知识,慢慢来,以后的训练跟着多练习!