Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
34011 yihang 【USACO】greetings C++ 通过 26 MS 8056 KB 585 2023-12-31 15:36:01

Tests(10/10):


#include"bits/stdc++.h" using namespace std; int a[1000000],b[1000000]; int main(){ int n,m,t1=0,p1=0,t2=0,p2=0,x,ans=0; char y; cin>>n>>m; for(int i=1;i<=n;i++){ cin>>x>>y; if(y=='L'){ while(x--){ t1--; p1++; a[p1]+=t1; }} else{ while(x--){ t1++; p1++; a[p1]+=t1; }}} for(int i=1;i<=m;i++){ cin>>x>>y; if(y=='L'){ while(x--){ t2--; p2++; b[p2]+=t2; }} else{ while(x--){ t2++; p2++; b[p2]+=t2; }}} for(int i=1;i<=1000000;i++){ if(i>p1)a[i]=t1; if(i>p2)b[i]=t2; if(a[i]==b[i]&&a[i-1]!=b[i-1])ans++;} cout<<ans;}


测评信息: