悬赏关注
  • 板块P1322 logo语言
  • 楼主OIer_hzn
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/1/28 09:31
  • 上次更新2023/10/24 02:52:42
查看原帖
悬赏关注
747142
OIer_hzn楼主2023/1/28 09:31

50pts

求助

//
//  main.cpp
//  IDE
//
//  Created by aa on 2022/12/30.
//
////
//
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdio>
using namespace std;
#define ll long long
const ll N=1000;
int fx[20]={-1,0,1,0,-1,1,1,-1};
int fy[20]={0,1,0,-1,1,-1,1,-1};
char a[N][N];
int d[N][N];
bool vis[N][N];
void inp_io(){
    std::ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int dfs(){
    string temp;
    int ans=0,k;
    char c,x;
    while(cin>>c){
        if(c==']') break;
        cin>>temp>>k;
        if(c=='R'){
            x=getchar();
            ans+=k*dfs();
            x=getchar();
        }if(c=='B'){
            x=getchar();
            ans-=k;
        }if(c=='F'){
            x=getchar();
            ans+=k;
        }if(x==']') break;
    }
    return ans;
}
int main(){
    inp_io();
    cout<<abs(dfs())<<endl;
    return 0;
}


2023/1/28 09:31
加载中...