Codeforces Round 910 (Div. 2)
1.Codeforces Round 909 (Div. 3)
2.Codeforces Round 910 (Div. 2)
3.Codeforces Round 912 (Div. 2)4.Educational Codeforces Round 158 (Rated for Div. 2)5.Codeforces Round 911 (Div. 2)6.[Educational Codeforces Round 159 (Rated for Div. 2)](https://codeforces.com/contest/1902)7.[Codeforces Round 855 (Div. 3)](https://codeforces.com/contest/1800)8.Codeforces Round 913 (Div. 3)9.Codeforces Round 904 (Div. 2)10.Codeforces Round 914 (Div. 2)11.Codeforces Round 917 (Div. 2)12.Codeforces [Hello 2024]13.Codeforces Round 919 (Div. 2)14.Codeforces Round 920 (Div. 3)Codeforces Round 910 (Div. 2)
A. Milica and String
wa麻了,,,不知道自己在干什么
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
int k,n;
string s;
cin>>n>>k>>s;
int cnt=0;
s = " " + s + " ";
for(int i=n+1;i;i--) if(s[i]=='B') cnt++;
if(cnt==k) cout<<0<<endl;
else if(cnt>k){
int cnt1=0;
cout<<1<<endl;
for(int i=n+1;i>0;i--){
if(s[i]=='B') cnt1++;
if(cnt1==k){
cout<<i-1<<" A"<<endl;
return;
}
}
}else{
int cnt1=0;
cout<<1<<endl;
for(int i=1;i<=n;i++){
if(s[i]=='A') cnt1++;
if(cnt1==k-cnt){
cout<<i<<" B"<<endl;
return;
}
}
}
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--)solve();
return 0;
}
B. Milena and Admirer
今天不宜写题
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 2e5 + 10;
int a[N];
int n;
void solve(){
cin>>n;
int ans=0;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=n-1;i>0;i--){
if(a[i]<=a[i+1]) continue;
int x=(a[i] + a[i+1] - 1)/a[i+1];
a[i]/=x;
ans+=x-1;
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--)solve();
return 0;
}
C. Colorful Grid
写着有点恶心,,,自己的码太丑了贴个佬的码
只要在起点处加个环,终点加个U型就行了
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
using LL = long long;
int main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T--){
int n, m, k;
cin >> n >> m >> k;
if (k < n + m - 2){
cout << "NO" << '\n';
continue;
}
if (k % 2 != (n + m - 2) % 2){
cout << "NO" << '\n';
continue;
}
vector<vector<int> > a1(n, vector<int>(m - 1)), a2(n - 1, vector<int>(m));
for(int i = 0; i < n - 1; i++){
if (i % 2 == 0){
a2[i][0] = 1;
}
}
for(int i = 0; i < m - 1; i++){
if ((n + i - 1) % 2 == 0){
a1[n - 1][i] = 1;
}
}
if (k % 4 != (n + m - 2) % 4){
a1[0][0] = a1[1][0] = 1;
}
a2[n - 2][m - 1] = a1[n - 1][m - 2] ^ 1;
a1[n - 2][m - 2] = a1[n - 1][m - 2];
a2[n - 2][m - 2] = a2[n - 2][m - 1];
cout << "YES" << '\n';
for(int i = 0; i < a1.size(); i++){
for(auto x : a1[i]){
cout << (x ? "R" : "B") << ' ';
}
cout << '\n';
}
for(int i = 0; i < a2.size(); i++){
for(auto x : a2[i]){
cout << (x ? "R" : "B") << ' ';
}
cout << '\n';
}
}
}
D
将每个集合当作一个线段。如果两个线段相交,对他们进行交换结果不变。如果两个线段不相交,假设[l1,r1],[l2,r2],l1<r1<l2<r2,对他们交换结果增大2*(l2-r1),因为只交换一次,所以我们要找到最大的那个左端点和最小的那个右端点。
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 2e5 + 10;
int n;
int a[N];
int b[N];
void solve(){
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) cin>>b[i];
int sum=0;
int maxl=0;
int minr=1e9;
for(int i=1;i<=n;i++){
sum+=abs(a[i]-b[i]);
maxl=max(maxl,min(a[i],b[i]));
minr=min(minr,max(a[i],b[i]));
}
if(maxl>=minr)sum+=2*(maxl-minr);
cout<<sum<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
}
合集:
cf
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧