Educational Codeforces Round 68 (Rated for Div. 2)(ABCD)

Remove a Progression CodeForces - 1194A
You have a list of numbers from 1 to n written from left to right on the blackboard.

You perform an algorithm consisting of several steps (steps are 1-indexed). On the i-th step you wipe the i-th number (considering only remaining numbers). You wipe the whole number (not one digit).
Educational Codeforces Round 68 (Rated for Div. 2)(ABCD)_第1张图片

When there are less than i numbers remaining, you stop your algorithm.

Now you wonder: what is the value of the x-th remaining number after the algorithm is stopped?

Input
The first line contains one integer T (1≤T≤100) — the number of queries. The next T lines contain queries — one per line. All queries are independent.

Each line contains two space-separated integers n and x (1≤x

Output
Print T integers (one per query) — the values of the x-th number after performing the algorithm for the corresponding queries.

Example
Input
3
3 1
4 2
69 6
Output
2
4
12
直接输出2*x就好了。。
代码如下:

#include
#define ll long long
using namespace std;

ll n,x;

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lld%lld",&n,&x);
		cout<<(x<<1L)<

Yet Another Crosses Problem CodeForces - 1194B
You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white.

You think that this picture is not interesting enough. You consider a picture to be interesting if there is at least one cross in it. A cross is represented by a pair of numbers x and y, where 1≤x≤n and 1≤y≤m, such that all cells in row x and all cells in column y are painted black.

For examples, each of these pictures contain crosses:
Educational Codeforces Round 68 (Rated for Div. 2)(ABCD)_第2张图片

The fourth picture contains 4 crosses: at (1,3), (1,5), (3,3) and (3,5).

Following images don’t contain crosses:
Educational Codeforces Round 68 (Rated for Div. 2)(ABCD)_第3张图片

You have a brush and a can of black paint, so you can make this picture interesting. Each minute you may choose a white cell and paint it black.

What is the minimum number of minutes you have to spend so the resulting picture contains at least one cross?

You are also asked to answer multiple independent queries.

Input
The first line contains an integer q (1≤q≤5⋅104) — the number of queries.

The first line of each query contains two integers n and m (1≤n,m≤5⋅104, n⋅m≤4⋅105) — the number of rows and the number of columns in the picture.

Each of the next n lines contains m characters — ‘.’ if the cell is painted white and ‘*’ if the cell is painted black.

It is guaranteed that ∑n≤5⋅104 and ∑n⋅m≤4⋅105.

Output
Print q lines, the i-th line should contain a single integer — the answer to the i-th query, which is the minimum number of minutes you have to spend so the resulting picture contains at least one cross.

Example
Input
9
5 5




3 4


.
.

4 3


*…
*…
*…
5 5


..*


.
…***
1 4


5 5


.
.


5 3

.
.
.*.


..
3 3
.
.
.
.*.
4 4
.*

.*
.*
Output
0
0
0
0
0
4
1
1
2
Note
The example contains all the pictures from above in the same order.

The first 5 pictures already contain a cross, thus you don’t have to paint anything.

You can paint (1,3), (3,1), (5,3) and (3,5) on the 6-th picture to get a cross in (3,3). That’ll take you 4 minutes.

You can paint (1,2) on the 7-th picture to get a cross in (4,2).

You can paint (2,2) on the 8-th picture to get a cross in (2,2). You can, for example, paint (1,3), (3,1) and (3,3) to get a cross in (3,3) but that will take you 3 minutes instead of 1.

There are 9 possible crosses you can get in minimum time on the 9-th picture. One of them is in (1,1): paint (1,2) and (2,1).
这个题过得听迷糊的,我以为用string不行呢,然后用数组试了几下,结果re和wa,用string之后就过了。
n*m反正不大,我把每一行和每一列的星星数记录下来,再去遍历每一行加每一列的个数,去更新最优值。
代码如下:

#include
#include
#include
#include
#include
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;

const int maxx=5e4+100;
string s[maxx];
int a[maxx];
int b[maxx];
int n,m;

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		scanf("%d%d",&n,&m);
		for(int i=0;i>s[i];
		int cnt=0;
		int i,j;
		for(i=0;i

From S To T CodeForces - 1194C
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.

During each operation you choose any character from p, erase it from p and insert it into string s (you may insert this character anywhere you want: in the beginning of s, in the end or between any two consecutive characters).

For example, if p is aba, and s is de, then the following outcomes are possible (the character we erase from p and insert into s is highlighted):

aba → ba, de → ade;
aba → ba, de → dae;
aba → ba, de → dea;
aba → aa, de → bde;
aba → aa, de → dbe;
aba → aa, de → deb;
aba → ab, de → ade;
aba → ab, de → dae;
aba → ab, de → dea;
Your goal is to perform several (maybe zero) operations so that s becomes equal to t. Please determine whether it is possible.

Note that you have to answer q independent queries.

Input
The first line contains one integer q (1≤q≤100) — the number of queries. Each query is represented by three consecutive lines.

The first line of each query contains the string s (1≤|s|≤100) consisting of lowercase Latin letters.

The second line of each query contains the string t (1≤|t|≤100) consisting of lowercase Latin letters.

The third line of each query contains the string p (1≤|p|≤100) consisting of lowercase Latin letters.

Output
For each query print YES if it is possible to make s equal to t, and NO otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).

Example
Input
4
ab
acxb
cax
a
aaaa
aaabbcc
a
aaaa
aabbcc
ab
baaa
aaaaa
Output
YES
YES
NO
NO
Note
In the first test case there is the following sequence of operation:

s= ab, t= acxb, p= cax;
s= acb, t= acxb, p= ax;
s= acxb, t= acxb, p= a.
In the second test case there is the following sequence of operation:

s= a, t= aaaa, p= aaabbcc;
s= aa, t= aaaa, p= aabbcc;
s= aaa, t= aaaa, p= abbcc;
s= aaaa, t= aaaa, p= bbcc.
就按着题意去不断的求解,找不符合的情况,之后就是符合的情况了。最后还dp求了一个最长公共子序列。。
代码如下:

#include
using namespace std;

char a[101],b[101],c[101];

int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%s%s%s",a+1,b+1,c+1);
		int len1=strlen(a+1);//s,s->t
		int len2=strlen(b+1);//t
		int len3=strlen(c+1);//p
		if(len1>len2)
		{
			puts("NO");
			continue;
		}
		map mp2,mp1,mp3;
		for(int i=1;i<=len2;i++) mp2[b[i]]++;
		int flag=0;
		for(int i=1;i<=len1;i++)
		{
			mp1[a[i]]++;
			if(mp1[a[i]]>mp2[a[i]])
			{
				flag=1;
				break;
			}
		}
		if(flag) puts("NO");
		else
		{
			for(int i=1;i<=len3;i++)
			{
				mp3[c[i]]++;
			}
			for(int i=1;i<=len2;i++)
			{
				if(mp1[b[i]]+mp3[b[i]]

1-2-K Game CodeForces - 1194D
Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. There is a chip placed in the n-th cell (the last one).

Players take turns, Alice is first. Each player during his or her turn has to move the chip 1, 2 or k cells to the left (so, if the chip is currently in the cell i, the player can move it into cell i - 1, i - 2 or i - k). The chip should not leave the borders of the paper strip: it is impossible, for example, to move it k cells to the left if the current cell has number i < k. The player who can’t make a move loses the game.

Who wins if both participants play optimally?

Alice and Bob would like to play several games, so you should determine the winner in each game.

Input
The first line contains the single integer T (1 ≤ T ≤ 100) — the number of games. Next T lines contain one game per line. All games are independent.

Each of the next T lines contains two integers n and k (0 ≤ n ≤ 109, 3 ≤ k ≤ 109) — the length of the strip and the constant denoting the third move, respectively.

Output
For each game, print Alice if Alice wins this game and Bob otherwise.

Example
Input
4
0 3
3 3
3 4
4 4
Output
Bob
Alice
Bob
Alice
sg函数打表找规律,看的题解,不怎么会博弈。。。
代码如下:

#include 
#define ll long long
using namespace std;
int f[35],sg[35],hashing[35];
void getsg(int n,int size)
{
    memset(sg,0,sizeof(sg));
    for(int i=0;i<=n;++i)//总个数
    {
        memset(hashing,0,sizeof(hashing));
        for(int j=0;f[j]<=i&&j

努力加油a啊,(o)/~

你可能感兴趣的:(Educational Codeforces Round 68 (Rated for Div. 2)(ABCD))