Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
34102 lance 【USACO】greetings C++ 通过 25 MS 8068 KB 725 2023-12-31 17:25:18

Tests(10/10):


#include <bits/stdc++.h> using namespace std; const int N=1e6+10; int s1[N],s2[N],p1,p2,t1,t2,b,e,ans; int main(){ cin>>b>>e; while(b--){ int x; char c; cin>>x>>c; if(c=='L'){ while(x--){ p1--; t1++; s1[t1]=p1; } } else { while(x--){ p1++; t1++; s1[t1]=p1; } } } while(e--){ int x; char c; cin>>x>>c; if(c=='L'){ while(x--){ p2--; t2++; s2[t2]=p2; } } else { while(x--){ p2++; t2++; s2[t2]=p2; } } } while(t1<t2){ s1[t1]=p1; t1++; } while(t2<t1){ s2[t2]=p2; t2++; } for(int i=1;i<=t1;i++){ if(s1[i]==s2[i]&&s1[i-1]!=s2[i-1])ans++; } cout<<ans; }


测评信息: