【题目链接】:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2133

【题意】

【题解】



考虑每一个二进制数的最高位->第i位;

肯定是1(这里不讨论0的情况)

然后对于其余n-1个二进制数;

如果它们在第i位和它一样->也是1的话,那么异或结果是0

那么不管第i位后面的位怎么变;它肯定是变小的->我们要求的

如果它们在第i为和它不一样->即为0,那么异或结果是1;

则它肯定是变大了;

综上

我们只要确定每个数的最高位所在的位置i

然后确定其他数字在第i位上是为1的数的个数cnt;

然后加上cnt就好;



【Number Of WA】



0



【完整代码】

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,m,rt<<1
  4. #define rson m+1,r,rt<<1|1
  5. #define LL long long
  6. #define rep1(i,a,b) for (int i = a;i <= b;i++)
  7. #define rep2(i,a,b) for (int i = a;i >= b;i--)
  8. #define mp make_pair
  9. #define ps push_back
  10. #define fi first
  11. #define se second
  12. #define rei(x) cin >> x
  13. #define pri(x) cout << x
  14. #define ms(x,y) memset(x,y,sizeof x)
  15. typedef pair<int,int> pii;
  16. typedef pair<LL,LL> pll;
  17. const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
  18. const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
  19. const double pi = acos(-1.0);
  20. const int N = 1e6+100;
  21. int T,n,m,top[N],tot[N];
  22. LL ans;
  23. string s;
  24. int main()
  25. {
  26. //freopen("F:\\rush.txt","r",stdin);
  27. ios::sync_with_stdio(false);
  28. cin >> T;
  29. while (T--)
  30. {
  31. ans = 0;
  32. cin >> n >> m;
  33. rep1(j,1,m) tot[j] = 0;
  34. rep1(i,1,n) top[i] = 0;
  35. rep1(i,1,n)
  36. {
  37. cin >> s;
  38. bool fi = true;
  39. rep1(j,1,m)
  40. {
  41. if (s[j-1]=='1')
  42. {
  43. if (fi) top[i] = j,fi = false;
  44. tot[j]++;
  45. }
  46. }
  47. }
  48. rep1(i,1,n)
  49. ans+=tot[top[i]];
  50. cout << ans << endl;
  51. }
  52. //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
  53. return 0;
  54. }

【郑轻邀请赛 G】密室逃脱的更多相关文章

  1. 【郑轻邀请赛 D】hipercijevi

    [题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2130 [题意] [题解] 把那个管泛化成一个点; 然后把每一个在管里面的点都和它相连 ...

  2. 【郑轻邀请赛 E】Can Win

    [题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2131 [题意] [题解] 尽量让自己喜欢的队赢; A内组内的比赛都让自己喜欢的队赢; ...

  3. 【郑轻邀请赛 H】 维克兹的进制转换

    [题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2134 [题意] [题解] 设f[i]表示数字i分解为二进制数的方案数; 则 如果i为 ...

  4. 【郑轻邀请赛 A】tmk射气球

    [题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2127 [题意] [题解] 把气球和飞艇所代表的直线投影到xoy面上 设气球所在位置为 ...

  5. 【郑轻邀请赛 B】base64解密

    [题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2128 [题意] [题解] 把密文; 在表中找到每个字符对应的数字; 然后转换成相应的 ...

  6. 【郑轻邀请赛 I】这里是天堂!

    [题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2135 [题意] [题解] 答案应该为C(n,a)∗C(m,b)/C(n+m,a+b) ...

  7. 【郑轻邀请赛 F】 Tmk吃汤饭

    [题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2132 [题意] [题解] 很容易想到用队列来模拟; 这个队列维护的是正在煮的4个人煮 ...

  8. 【郑轻邀请赛 C】DOBRI

    [题目链接]:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2129 [题意] [题解] NMB 直接说i-1,i-2,i-3不就好了- [Numb ...

  9. 基于Spring MVC + Spring + MyBatis的【密室逃脱游戏主题排行榜】

    资源下载: https://download.csdn.net/download/weixin_44893902/25706959 一.语言和环境 1. 实现语言:Java语言 2. 环境要求:ecl ...

随机推荐

  1. open_basedir restriction in effect,解决php引入文件权限问题 lnmp

    1.配置了虚拟域名 vim /usr/local/nginx/conf/vhost/siemens.conf server { listen 80; #listen [::]:80 default_s ...

  2. bzoj 3895 取石子 —— 博弈论

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3895 看了博客:https://blog.csdn.net/popoqqq/article/ ...

  3. codevs1154能量项链(环形dp,区间dp)

    1154 能量项链 2006年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold     题目描述 Description 在Mars星球上 ...

  4. 数据库部署到linux服务器,供本地访问。

    1.  将本地的sql文件上传至服务器 scp /Users/fangke/Documents/article.sql root@IP:/usr/local 2. 登陆服务器的mysql 3. 创建数 ...

  5. strupr函数

    2019-06-03 15:13:39 strupr()函数! strupr,函数的一种,将字符串s转换为大写形式. 说明:只转换s中出现的小写字母,不改变其它字符.返回指向s的指针. 兼容性说明:s ...

  6. int(3)和int(11)区别

  7. 《Typecript 入门教程》 3、接口

    转载:<TypeScript 中文入门教程> 3.接口 介绍 TypeScript的核心原则之一是对值所具有的shape进行类型检查. 它有时被称做“鸭式辨型法”或“结构性子类型化”. 在 ...

  8. linux 防火墙关闭

     systemctl status firewalld.servicesystemctl status iptables.service关闭防火墙,selinux15:54:43运维-李浩 2017/ ...

  9. 手势识别官方教程(7)识别缩放手势用ScaleGestureDetector和SimpleOnScaleGestureListener

    1.Use Touch to Perform Scaling As discussed in Detecting Common Gestures, GestureDetector helps you ...

  10. 利用python去除红章

    近期接的一个需求需要去除图片的红章,用到了PIL库. from PIL import Image,ImageEnhanceimport os#f="5-12 - 0001.tif" ...