比赛 20241023 评测结果 WWWWWWWWWWWWWWWWWWWW
题目名称 Cowreography 最终得分 0
用户昵称 wdsjl 运行时间 0.673 s
代码语言 C++ 内存使用 4.60 MiB
提交时间 2024-10-23 11:33:04
显示代码纯文本
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 2e6+10;
  5.  
  6. int n,k,ans;
  7. char a[N],b[N];
  8.  
  9. int main(){
  10. freopen("cowreography.in","r",stdin);
  11. freopen("cowreography.out","w",stdout);
  12. scanf("%d%d",&n,&k);
  13. cin>>(a+1);
  14. cin>>(b+1);
  15. if(k==1){
  16. ans=0;
  17. int j=1,pre=1;
  18. for(int i=1;i<=n;i++){
  19. if(a[i]=='1'){
  20. while(b[j]!='1')j++;
  21. pre=j;
  22. ans+=abs(i-j);
  23. j++;
  24. // cout<<i<<" "<<j<<endl;
  25. }
  26. }
  27. printf("%d",ans);
  28. }
  29. return 0;
  30. }