其他分享
首页 > 其他分享> > 补 : Codeforces Round #700 (Div. 2) A B

补 : Codeforces Round #700 (Div. 2) A B

作者:互联网

只做出了A,B。C本来蒙了一次,数据太弱给过了,就睡觉去了,早上起来C就没了,果然CF木有运气。

目录

A. Yet Another String Game

题目思路: 如果是A的操作的话,尽量把字母变成a,如果原来是a,就变成b,B的操作的是把字母尽量变成z,如果没z,就变成y.原题目中的这三句话决定了策略。

A string a is lexicographically smaller than a string b if and only if
one of the following holds:

  • a is a prefix of b, but a≠b;
  • in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding
    letter in b.
#include<bits/stdc++.h>
#define fi first
#define endl "\n"
#define se second
#define PI acos(-1)
#define inf 0x3f3f3f3f
#define mm(a, b) memset(a, b, sizeof(a))
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug freopen("1.in", "r", stdin), freopen("1.out", "w", stdout);
using namespace std;
typedef long long ll;
typedef pair<int , int> PII;
const int N = 1e5 + 10;

int t; 
string a;

int main()
{
	scanf("%d", &t);
	while(t --)
	{
		cin >> a;
		int len = a.size();
		int cnt = 1;
		// 1 shi a
		// ou shi b
		for(int i = 0;i < a.size();i ++)
		{
			if(cnt & 1)
			{
				if(a[i] != 'a')a[i] = 'a';
				else a[i] = 'b';
				cnt ++;
			}
			else
			{
				if(a[i] != 'z') a[i] = 'z';
				else a[i] = 'y';
				cnt ++;
			}
		}
		cout << a << endl;
	}
	return 0;
}

B-The Great Hero

比赛没开long long ,又重新交了一次,唉 ,少了好多分。

题目思路: 把伤害最高的放在最后,因Hero可能与这个同归于尽。

#include<bits/stdc++.h>
#define fi first
#define endl "\n"
#define se second
#define PI acos(-1)
#define inf 0x3f3f3f3f
#define mm(a, b) memset(a, b, sizeof(a))
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug freopen("1.in", "r", stdin), freopen("1.out", "w", stdout);
using namespace std;
typedef long long ll;
typedef pair<int , int> PII;
const int N = 1e5 + 10;
 
int t; 
struct Guai{
	ll gong;ll xie;
}guai[N];
 
bool cmp(Guai a, Guai b)
{
	if(a.gong == b.gong)
	{
		return a.xie < b.xie;
	}
	return a.gong < b.gong;
}
int main()
{
	scanf("%d", &t);
	while(t --)
	{
		ll gj, hp, n;
		scanf("%lld%lld%lld", &gj, &hp, &n);
		
		for(int i = 0;i < n;i ++)
			scanf("%lld", &guai[i].gong);
		for(int i = 0;i < n;i ++)
			scanf("%lld", &guai[i].xie);
		sort(guai, guai + n, cmp);
		
		int cnt = 0;
		for(int i = 0;i < n;i ++)
		{
		    ll num1 = (hp + guai[i].gong - 1) / guai[i].gong;
		    ll num2 = (guai[i].xie + gj - 1) / gj;
		    ll num3 = min(num1, num2);
		    hp = hp - guai[i].gong * num3;
		    guai[i].xie = guai[i].xie - gj * num3; 
			if(guai[i].xie <= 0)cnt ++;
			if(hp <= 0)break;
		}
		if(cnt == n)puts("YES");
		else puts("NO");
	}
	return 0;
}

C. Searching Local Minimum

这个题目是二分题目,很容易看出来,但是 交互式的 题目不怎么会写,再加上二分掌握不是很熟练,一波大分就没了。

题目思路:

标签:gong,xie,int,ll,700,Codeforces,guai,Div,define
来源: https://blog.csdn.net/m0_51990674/article/details/113756857