傻逼题,但是为什么别人的O(n^3)不会T?只是因为用了bitset优化。。。

附上一张bitset基本操作的表

#include<bits/stdc++.h>
using namespace std; const int maxn = +; char g[maxn][maxn]; bitset<maxn> b1[maxn],b2[maxn],res; #define local
int main()
{
#ifdef local
freopen("triatrip.in","r",stdin);
freopen("triatrip.out","w",stdout);
#endif // local
int n; scanf("%d",&n);
for(int i = ; i < n; i++){
scanf("%s",g[i]);
}
for(int i = ; i < n; i++)
for(int j = ; j < n; j++)
if(g[i][j] == '+') b1[i][j] = , b2[j][i] = ; long long ans = ;
for(int i = ; i < n; i++)
for(int j = ; j < n; j++) if(b1[i][j]){
res = b1[j]&b2[i];
ans += res.count();
} printf("%I64d\n",ans/);
return ;
}

codeforce Gym 100342J Triatrip (bitset)的更多相关文章

  1. Gym - 100342J Triatrip (bitset求三元环个数)

    https://vjudge.net/problem/Gym-100342J 题意:给出一个邻接矩阵有向图,求图中的三元环的个数. 思路: 利用bitset暴力求解,记得最后需要/3. #includ ...

  2. 【CF1097F】Alex and a TV Show(bitset)

    [CF1097F]Alex and a TV Show(bitset) 题面 洛谷 CF 题解 首先模\(2\)意义下用\(bitset\)很明显了. 那么问题在于怎么处理那个\(gcd\)操作. 然 ...

  3. 3687: 简单题(bitset)

    3687: 简单题 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 700  Solved: 319[Submit][Status][Discuss] ...

  4. [Bzoj5285][洛谷P4424][HNOI/AHOI2018]寻宝游戏(bitset)

    P4424 [HNOI/AHOI2018]寻宝游戏 某大学每年都会有一次Mystery Hunt的活动,玩家需要根据设置的线索解谜,找到宝藏的位置,前一年获胜的队伍可以获得这一年出题的机会. 作为新生 ...

  5. 【科技】位运算(bitset)优化最长公共子序列算法

    最长公共子序列(LCS)问题 你有两个字符串 \(A,B\),字符集为 \(\Sigma\),求 \(A, B\) 的最长公共子序列. 简单动态规划 首先有一个广为人知的 dp:\(f_{i,j}\) ...

  6. Atcoder Regular Contst 084 D - XorShift(bitset)

    洛谷题面传送门 & Atcoder 题面传送门 没错,这就是 Small Multiple 那场的 F,显然这种思维题对我来说都是不可做题/cg/cg/cg 首先如果我们把每个二进制数看作一个 ...

  7. codeforce No to Palindromes!(枚举)

    /* 题意:给定一个字符串中没有任何长度>1的回文子串!求按照字典序的该串的下一个字符串 也不包含长度>1的任何回文子串! 思路:从最低位进行枚举,保证第i位 不与 第 i-1位和第 i- ...

  8. [codeforce 975C] Valhalla Siege (二分)

    Examples input 5 5 1 2 1 2 1 3 10 1 1 1 output 3 5 4 4 3 input 4 4 1 2 3 4 9 1 10 6 output 1 4 4 1 N ...

  9. Gym - 101617D_Jumping Haybales(BFS)

    Sample Input 4 2 .### #... .#.. #.#. 3 1 .#. .#. .#. Sample Output 4 -1 题意:给一个n*n的图,每次最多能跳k个格子,只能向南( ...

随机推荐

  1. java之数学方法

    参考http://how2j.cn/k/number-string/number-string-math/319.html java.lang.Math提供了一些常用的数学运算方法,并且都是以静态方法 ...

  2. yzm10与战地信使 yzm10原创系列

    yzm10与战地信使 M国与R国正进行着激烈的鏖战,此时的yzm10从R国窃取了最高军事机密,这份情报将是此次战役的转折点,如果M国得到了这份情报,就能够取得这次战争的胜利.yzm10当然是站在M国这 ...

  3. Beetl使用注意事项

    1.如果表达式跟定界符或者占位符有冲突,可以在用 “\” 符号 @for(user in users){ email is ${user.name}\@163.com @} ${[1,2,3]} // ...

  4. PHP注释-----PHPDOC

    用过IDE或看过其他源码的小伙伴们应该都见过类似下面这样的注释   /** * 递归获取所有游戏分类 * @param int $id * @return array */ 看得多了就大概知道了一些规 ...

  5. WPF在ViewModel中绑定按钮点击(CommandBase定义)

    定义CommandBase public class CommandBase:ICommand { private readonly Action<object> _commandpara ...

  6. Centos7.1下Docker的安装-yum方法

    在CentOS7上安装1. 查看系统版本: $ cat /etc/redhat-release CentOS Linux release 7.0.1406 (Core) 2. 安装docker $ y ...

  7. Kth Largest Element in a Stream

    Design a class to find the kth largest element in a stream. Note that it is the kth largest element ...

  8. Unite 2017 | 基于Animation Instancing的大规模人群模拟

    在Unite 2017的国内技术专场,Unity技术团队为参会者们带来了Unity引擎功能相关的技术分享.今天这篇文章,将由Unity技术支持工程师金晓宇为大家分享基于Animation Instan ...

  9. 洛谷P2899 [USACO08JAN]手机网络Cell Phone Network

    P2899 [USACO08JAN]手机网络Cell Phone Network 题目描述 Farmer John has decided to give each of his cows a cel ...

  10. IT兄弟连 Java语法教程 Java语言的其他特性

    Java语言中除了非常重要的跨平台特性外,还有如下几个关键特性: ●  语法简单易学 Java语言的语法简单明了,容易掌握,而且是纯面向对象(OOP)的语言,Java语言的简单性主要体现在以下几个方面 ...