Codeforces Round 863 (Div. 3)

Posted Harper886’s Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round 863 (Div. 3)相关的知识,希望对你有一定的参考价值。

Codeforces Round 863 (Div. 3)

链接

Codeforces Round 863 (Div. 3)

A题

遍历这个字符串,如果要插入的数第一次小于当前的数,就将数插入到这里,如果到最后都没有插入数,插入到最后

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cstring>
#include <unordered_set>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <sstream>
#include <queue>
#define int long long
#define yes cout<<"YES"<<\'\\n\'
#define no 	cout<<"NO"<<\'\\n\'

using namespace std;
const int N = 100008;

void solve() 
	int n, x;
	scanf("%lld %lld", &n, &x);
	string s;
	cin >> s;
	int flag = 0;
	for (int i = 0; i < (int)s.size(); i++) 
		if (x > (s[i] - \'0\') && flag == 0) //如果从来没插入过,并且大于当前的数字
			cout << x << s[i];//打印x和s[i]
			flag++;
		 else 
			cout << s[i];//否则只打印当前的s[i]
		
	
	if (flag == 0) //没有打印过x
		cout << x;//在最后打印

	
	cout << \'\\n\';




signed main () 
	int t;
	cin >> t;
	while (t) 
		solve();
		t--;
	


	return 0;



B题

比赛的时候看错题了,现在感觉好像看对也写不出来

这个题其实就是问两个点相距多少层,将两层相减取绝对值就可以.现在是怎么求出这个点所在的层数,可以发现点(x,y)和边界的距离最短的那个就是层数,就是min(x,y,n-x+1,n-y+1)的值.

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cstring>
#include <unordered_set>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <sstream>
#include <queue>
#define int long long
#define yes cout<<"YES"<<\'\\n\'
#define no 	cout<<"NO"<<\'\\n\'

using namespace std;
const int N = 100008;

void solve() 
	int n;
	cin >> n;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a = min(min(x1, y1), min(n - x1 + 1, n - y1 + 1));//求x1,y1的层数
	int b = min(min(x2, y2), min(n - x2 + 1, n - y2 + 1));//求x2,y2的层数

	printf("%lld\\n", abs(a - b));//打印abs(a-b);


signed main () 
	int t;
	cin >> t;
	while (t) 
		solve();
		t--;
	


	return 0;

Codeforces Round #735 (Div. 2)

Codeforces Round #735 (Div. 2)

题海题目知识点
ACherry
BCobb
CMikasa
DDiane
EYou

以上是关于Codeforces Round 863 (Div. 3)的主要内容,如果未能解决你的问题,请参考以下文章

E. Turn Off The TV Educational Codeforces Round 29

Codeforces Round #705 (Div. 2)

Codeforces Round #774 (Div. 2)

Codeforces Round #808 (Div. 1)(A~C)

Codeforces Round #717 (Div. 2)

Codeforces Round #784 (Div. 4)