专栏文章
【八月份 -- 基础语法组】-- T4 -- 教室
个人记录参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mipc3vys
- 此快照首次捕获于
- 2025/12/03 09:34 3 个月前
- 此快照最后确认于
- 2025/12/03 09:34 3 个月前
https://cspjs.online/contest/756/problem/4
CPP#include<bits/stdc++.h>
#define LL long long
using namespace std;
void solve(int n,int m){
deque<int> Q;
for(int i=0;i<n;i++){
int a;
cin>>a;
Q.push_back(a);
}
for(int i=0;i<m;i++){
char c;
cin>>c;
if(c=='L'){
int l=Q.front();
Q.pop_front();
Q.front()+=l;
Q.push_back(0);
}
else{
int r=Q.back();
Q.pop_back();
Q.back()+=r;
Q.push_front(0);
}
}
for(int i=0;i<n;i++)cout<<Q[i]<<(i+1==n ? "\n":" ");
}
int main(){
freopen("room.in","r",stdin);
freopen("room.out","w",stdout);
int n,m;
cin>>n>>m;
solve(n,m);
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...