提交时间:2023-12-31 11:17:44

运行 ID: 33728

#include<iostream> using namespace std; int bd[1000005],ed[1000005]; int main(){ int B,E,bx=0,bt=0,ex=0,et=0,ans=0; cin>>B>>E; while(B--){ int x; char f; cin>>x>>f; while(x--){ if(f=='L')bd[++bt]=--bx; else bd[++bt]=++bx; } } while(E--){ int x; char f; cin>>x>>f; while(x--){ if(f=='L')ed[++et]=--ex; else ed[++et]=++ex; } } int t=max(bt,et); while(bt<=t)bd[++bt]=bx; while(et<=t)ed[++et]=ex; for(int i=1;i<=t;i++){ if(bd[i]==ed[i]&&bd[i-1]!=ed[i-1])ans++; } cout<<ans; return 0; }