社区讨论

求调

P9539 「AWOI Round 2 B」树学参与者 2已保存回复 3

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@lo1to57r
此快照首次捕获于
2023/10/23 02:48
2 年前
此快照最后确认于
2023/11/03 03:22
2 年前
查看原帖
AC 10,其余全WA
CPP
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const double pi = 3.1415926535897932385;
typedef long long ll;
typedef pair<int,int> Pr;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, eps=1e3+10, maxn=1e6+10;
template <typename T> inline void read(T &x) {
	x = 0;
	bool flag = false;
	char ch = getchar();
	while (ch < '0' || ch > '9') flag = ch == '-' ? true : false, ch = getchar();
	while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch & 15), ch = getchar();
	if(flag) x = -x;
}
template <typename T> inline void write(T x) {
	if(x<0) {
		putchar('-');
		x = -x;
	}
	if(x>9) write(x / 10);
	putchar(x % 10 + '0');
}
ll n, l, r;
string s;
int main() {
    read(n), read(l), read(r);
    cin >> s;
    if(n == l){
    	cout << s;
    	return 0;
	}
	else if(l == 0){
		for(int i = 0;i < s.size(); ++i){
			s[i] = 'a'; 
		}
		cout << s;
		return 0;
	}
	ll cnt = n - l;
	for(int i = 0;i < s.size(); ++i){
		if(cnt == 0) break;
		if(s[i] == 'a') continue;
		cnt--;
		s[i] = 'a';
	}
	cout << s;
	return 0;
}

回复

3 条回复,欢迎继续交流。

正在加载回复...