刷水QwQ
纯模拟
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #define maxn 3000 using namespace std; int n,num_a,num_b,a[maxn],b[maxn]; int ans_a,ans_b; int main() { scanf("%d%d%d",&n,&num_a,&num_b); for(register int i=1;i<=num_a;++i) scanf("%d",&a[i]); for(register int i=1;i<=num_b;++i) scanf("%d",&b[i]); int p1=0,p2=0; for(register int i=1;i<=n;++i) { p1++; p2++; if(p1>num_a) p1=1; if(p2>num_b) p2=1; if(a[p1]==0) { if(b[p2]==2||b[p2]==3) ++ans_a; if(b[p2]==1||b[p2]==4) ++ans_b; } else if(a[p1]==1) { if(b[p2]==3||b[p2]==0) ++ans_a; if(b[p2]==2||b[p2]==4) ++ans_b; } else if(a[p1]==2) { if(b[p2]==1||b[p2]==4) ++ans_a; if(b[p2]==0||b[p2]==3) ++ans_b; } else if(a[p1]==3) { if(b[p2]==4||b[p2]==2) ++ans_a; if(b[p2]==0||b[p2]==1) ++ans_b; } else if(a[p1]==4) { if(b[p2]==0||b[p2]==1) ++ans_a; if(b[p2]==2||b[p2]==3) ++ans_b; } } printf("%d %d",ans_a,ans_b); return 0; }