Codeforces [Hello 2024]
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 Hello 2024
主打一个昏了头
A. Wallet Exchange
#include <bits/stdc++.h>
#define endl '\n'
//#define int long long
using namespace std;
const int N = 2e5 + 10;
int a,b;
void solve(){
cin>>a>>b;
if((a+b)&1) cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T = 1;
cin >> T;
while(T--) solve();
return 0;
}
B. Plus-Minus Split
#include <bits/stdc++.h>
#define endl '\n'
//#define int long long
using namespace std;
const int N = 2e5 + 10;
void solve(){
string s;
int n;
cin>>n>>s;
long long ans = 0;
deque<int> path;
for(int i=0;i<n;i++){
int x;
if(s[i]=='+') x=1;
else x=-1;
if(!path.size()) path.push_back(x);
else{
if(x+path.back()==0) path.pop_back();
else path.push_back(x);
}
}
cout << path.size() <<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. Grouping Increases
昨晚贪半天没贪明白也是蠢
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N = 2e5 + 10;
int n;
int a[N];
void solve(){
cin >> n;
for(int i = 1; i <= n;i++) cin>>a[i];
deque<int> path1,path2;
path1.push_back(1e10);
path2.push_back(1e10);
for(int i=1;i<=n;i++)
{
int x=path1.back();
int y=path2.back();
if(a[i]<=x&&a[i]<=y)
{
if(x<=y) path1.push_back(a[i]);
else path2.push_back(a[i]);
}else
if(a[i]>x&&a[i]>y)
{
if(x<=y) path1.push_back(a[i]);
else path2.push_back(a[i]);
}
else if(a[i]<=x) path1.push_back(a[i]);
else if(a[i]<=y) path2.push_back(a[i]);
}
long long ans = 0;
for(int i=1;i+1<path1.size();i++)
if(path1[i]<path1[i+1]) ans++;
for(int i=1;i+1<path2.size();i++)
if(path2[i]<path2[i+1]) ans++;
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;
}
D. 01 Tree
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N = 2e5 + 10;
int a[N];
int l[N];
int r[N];
void del(int x){
r[l[x]] = r[x];
l[r[x]] = l[x];
}
void solve(){
int n;
cin >> n;
vector<vector<int>> G(n+1);
for(int i=1;i<=n;i++)
{
cin >> a[i];
G[a[i]].push_back(i);
l[i] = i-1;
r[i] = i+1;
}
if(G[0].size()!=1)
{
cout << " NO " <<endl;
return;
}
for(int i=n-1;i>0;i--)
{
int ll,rr;
for(int j=0;j<G[i].size();j++)
{
ll=j;
while(j+1<G[i].size()&&r[G[i][j]]==G[i][j+1]) j++;
rr=j;
//cout<<ll<<" "<<rr<<endl;
if((r[G[i][rr]]<=n&&a[r[G[i][rr]]]==i-1)||(l[G[i][ll]]>0&&a[l[G[i][ll]]]==i-1))
{
}else{
// cout<<ll<<" "<<rr<<endl;
// cout<<r[G[i][rr]]<<" "<<a[r[G[i][rr]]]<<endl;
// cout<<l[G[i][ll]]<<" "<<a[G[i][ll]-1]<<endl;
// cout<<i<<" "<<j<<" "<<G[i][j]<<endl;
cout<<"NO"<<endl;
return;
}
for(int k=ll;k<=rr;k++) del(G[i][k]);
j = rr;
}
}
cout<<"YES"<<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T = 1;
cin >> T;
while(T--) solve();
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧