AtCoder Beginner Contest 244 打比赛总结

8 篇文章 0 订阅
7 篇文章 2 订阅

又打了一场ABC。 

AtCoder Beginner Contest 244 - AtCoderhttps://atcoder.jp/contests/abc244结果:A,B(300分)。

A题:

A - Last Letter / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100 points

Problem Statement
Given a string S of length N consisting of lowercase English alphabets, print the last character of S.

Constraints
N is an integer.
1≤N≤1000
S is a string of length N consisting of lowercase English alphabets.
Input
Input is given from Standard Input in the following format:

N
S
Output
Print the last character of S.

Sample Input 1 
Copy
5
abcde
Sample Output 1 
Copy
e
The last character of S=abcde is e, so e should be printed.

Sample Input 2 
Copy
1
a
Sample Output 2 
Copy
a

题目大意:输入一个字符串的长度,再输入字符串,输出最后一位的字符。

思路:即输出字符串的第长度减一位。

AC代码(此题太水):

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	cout<<s[n-1];
                                                                                                                                                                                                                                                                                  
    return 0;
}
//ACplease!!!


/*  printf("                                                                \n");
	printf("                                                                \n");
	printf("       * * *               * * *             * * *             * * *            \n");
	printf("     *       *           *       *         *      *          *       *         \n");
	printf("    *        *          *         *       *        *        *         *        \n");
	printf("            *           *         *                *                  *      \n");
	printf("           *            *         *               *                  *     \n");
	printf("          *             *         *              *                  *       \n");
	printf("         *              *         *             *                  *            \n");
	printf("        *               *         *           *                  *            \n");
	printf("      *                  *       *          *                  *           \n");
	printf("    * * * * * * *          * * *          * * * * * * *      * * * * * * *                           \n");
*/    

B题:

B - Go Straight and Turn Right  / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 200 points

Problem Statement
Consider an xy-plane. The positive direction of the x-axis is in the direction of east, and the positive direction of the y-axis is in the direction of north.
Takahashi is initially at point (x,y)=(0,0) and facing east (in the positive direction of the x-axis).

You are given a string T=t 
1
​	
 t 
2
​	
 …t 
N
​	
  of length N consisting of S and R. Takahashi will do the following move for each i=1,2,…,N in this order.

If t 
i
​	
 = S, Takahashi advances in the current direction by distance 1.
If t 
i
​	
 = R, Takahashi turns 90 degrees clockwise without changing his position. As a result, Takahashi's direction changes as follows.
If he is facing east (in the positive direction of the x-axis) before he turns, he will face south (in the negative direction of the y-axis) after he turns.
If he is facing south (in the negative direction of the y-axis) before he turns, he will face west (in the negative direction of the x-axis) after he turns.
If he is facing west (in the negative direction of the x-axis) before he turns, he will face north (in the positive direction of the y-axis) after he turns.
If he is facing north (in the positive direction of the y-axis) before he turns, he will face east (in the positive direction of the x-axis) after he turns.
Print the coordinates Takahashi is at after all the steps above have been done.

Constraints
1≤N≤10 
5
 
N is an integer.
T is a string of length N consisting of S and R.
Input
Input is given from Standard Input in the following format:

N
T
Output
Print the coordinates (x,y) Takahashi is at after all the steps described in the Problem Statement have been completed, in the following format, with a space in between:

x y
Sample Input 1 
Copy
4
SSRS
Sample Output 1 
Copy
2 -1
Takahashi is initially at (0,0) facing east. Then, he moves as follows.

t 
1
​	
 = S, so he advances in the direction of east by distance 1, arriving at (1,0).
t 
2
​	
 = S, so he advances in the direction of east by distance 1, arriving at (2,0).
t 
3
​	
 = R, so he turns 90 degrees clockwise, resulting in facing south.
t 
4
​	
 = S, so he advances in the direction of south by distance 1, arriving at (2,−1).
Thus, Takahashi's final position, (x,y)=(2,−1), should be printed.

Sample Input 2 
Copy
20
SRSRSSRSSSRSRRRRRSRR
Sample Output 2 
Copy
0 1

题目大意:输入一个字符串的长度,再输入包含R,S字符串。高桥在坐标0,0处,面向东方。执行字符串中的命令:S表示像面朝的方向走一步,R表示以顺时针方向旋转90度。输出执行命令后的坐标,两数用空格隔开。

思路:略,按命令执行即可。

AC代码(此题有点水):

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	
	string s;
	cin>>s;
	
	int x=0,y=0,d=0; //0.东/1.南/2.西/3.北 
	for(int i=0;i<(int)s.size();i++){
		if(s[i]=='S'){
			if(d==0)
			    x++;
			else if(d==1)
			    y--;
			else if(d==2)
			    x--;
			else 
			    y++;
		}
		else{
			if(d==0)
			    d=1;
			else if(d==1)
			    d=2;
			else if(d==2)
			    d=3;
			else 
			    d=0;
		}
	}
    
	cout<<x<<" "<<y;
	                                                                                                                                                                                                                                                                              
    return 0;
}
//ACplease!!!


/*  printf("                                                                \n");
	printf("                                                                \n");
	printf("       * * *               * * *             * * *             * * *            \n");
	printf("     *       *           *       *         *      *          *       *         \n");
	printf("    *        *          *         *       *        *        *         *        \n");
	printf("            *           *         *                *                  *      \n");
	printf("           *            *         *               *                  *     \n");
	printf("          *             *         *              *                  *       \n");
	printf("         *              *         *             *                  *            \n");
	printf("        *               *         *           *                  *            \n");
	printf("      *                  *       *          *                  *           \n");
	printf("    * * * * * * *          * * *          * * * * * * *      * * * * * * *                           \n");
*/    

C题:

C - Yamanote Line Game  / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 300 points

Problem Statement
Takahashi and Aoki will play the following game against each other.

Starting from Takahashi, the two alternatingly declare an integer between 1 and 2N+1 (inclusive) until the game ends. Any integer declared by either player cannot be declared by either player again. The player who is no longer able to declare an integer loses; the player who didn't lose wins.

In this game, Takahashi will always win. Your task is to actually play the game on behalf of Takahashi and win the game.

Constraints
1≤N≤1000
N is an integer.
Input and Output
This task is an interactive task (in which your program and the judge program interact with each other via inputs and outputs).
Your program plays the game on behalf of Takahashi, and the judge program plays the game on behalf of Aoki.

First, your program is given a positive integer N from Standard Input. Then, the following procedures are repeated until the game ends.

Your program outputs an integer between 1 and 2N+1 (inclusive) to Standard Output, which defines the integer that Takahashi declares. (You cannot output an integer that is already declared by either player.)
The integer that Aoki declares is given by the judge program to your program from Standard Input. (No integer that is already declared by either player will be given.) If Aoki has no more integer to declare, 0 is given instead, which means that the game ended and Takahashi won.
Notes
After each output, you must flush Standard Output. Otherwise, you may get .
After the game ended and Takahashi won, the program must be terminated immediately. Otherwise, the judge does not necessarily give .
If your program outputs something that violates the rules of the game (such as an integer that has already been declared by either player), your answer is considered incorrect. In such case, the verdict is indeterminate. It does not necessarily give .
Sample Input and Output
Input	Output	Description
2		First, an integer N is given.
1	Takahashi declares an integer 1.
3		Aoki declares an integer 3.
2	Takahashi declares an integer 2.
4		Aoki declares an integer 4.
5	Takahashi declares an integer 5.
0		Aoki has no more integer to declare, so Takahashi wins, and the game ends.

题目大意:略,自己看翻译去。

思路:以交互题思路做题。

 TLE代码(TLE了9次,这里选其中一个展示):

#include<bits/stdc++.h>
using namespace std;
int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(0);
	
	int n,f[2022];
	scanf("%d",&n);
    for(int i=0;i<=2*n+1;i++)
	    f[i]=1;
	
	for(int i=1;i<=n+1;i++){
		int t;
		scanf("%d",&t);
		f[t]=0;	
	}
	
	for(int i=1;i<=2*n+1;i++)
		if(f[i]){
			printf("%d\n",i);
			fflush(stdout);
		}
	
	cout<<0;
		                                                                                                                                                                                                                                                                                
    return 0;
}
//ACplease!!!

/*  printf("                                                                \n");
	printf("                                                                \n");
	printf("       * * *               * * *             * * *             * * *            \n");
	printf("     *       *           *       *         *      *          *       *         \n");
	printf("    *        *          *         *       *        *        *         *        \n");
	printf("            *           *         *                *                  *      \n");
	printf("           *            *         *               *                  *     \n");
	printf("          *             *         *              *                  *       \n");
	printf("         *              *         *             *                  *            \n");
	printf("        *               *         *           *                  *            \n");
	printf("      *                  *       *          *                  *           \n");
	printf("    * * * * * * *          * * *          * * * * * * *      * * * * * * *                           \n");
*/    

D题不说了,WA

其他题更别提了……

AB两题13分钟AC,剩下时间就在搞CD……

呵呵o(* ̄︶ ̄*)o,继续努力吧!(排名5239)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值