当前位置:网站首页>[at] abc 258G - Triangle 三元组可达-暴力
[at] abc 258G - Triangle 三元组可达-暴力
2022-07-03 07:42:00 【*DDL_GzmBlog】
前言
t a g : tag : tag:bitset01图
传送门:
题意 :
给定一个 01 01 01完全图, 1 1 1表示这两个点有边相连, 0 0 0表示这两个点没有边相连
询问有多少组三元组 ( i , j , k ) (i,j,k) (i,j,k),满足两两之间有边相连
思路 :
暴力的做法 n 3 n^3 n3,因为图只存在 01 01 01,我们考虑使用位运算减去一层的枚举
即bitset , 我们将状态存入biset中,然后枚举两行之间的状态,进行 & \& &运算
显然的如果 & = 1 \&=1 &=1那么,存在三个点是可达的,时间复杂度 n 2 l o g n n^2logn n2logn
code :
void solve(){
int n;cin>>n;
vector<bitset<N>> v(n);
vector<string> s(n);
for(int i = 0; i < n; i ++ ){
cin>>s[i];
for(int j = 0 ; j < n ; j ++ ){
if(s[i][j] == '1') v[i][j] = 1;
}
}
ll ans = 0 ;
for(int i = 0 ; i< n ; i ++ ){
for(int j = 0 ; j< i ; j ++ ){
if(s[i][j] == '1') ans += (v[i]&v[j]).count();
}
}
cout<<ans/3<<endl;
}
int main(){
//int t;cin>>t;while(t--)
solve();
return 0 ;
}
边栏推荐
- 截图工具Snipaste
- OSPF experiment
- PAT甲级 1030 Travel Plan
- PAT甲级 1027 Colors in Mars
- Lombok -- simplify code
- Professor Zhang Yang of the University of Michigan is employed as a visiting professor of Shanghai Jiaotong University, China (picture)
- Go language foundation ----- 08 ----- interface
- Analysis of the problems of the 10th Blue Bridge Cup single chip microcomputer provincial competition
- Technical dry goods Shengsi mindspire innovation model EPP mvsnet high-precision and efficient 3D reconstruction
- lucene scorer
猜你喜欢

Application of pigeon nest principle in Lucene minshouldmatchsumscorer

截图工具Snipaste

Technology dry goods | luxe model for the migration of mindspore NLP model -- reading comprehension task

Qtip2 solves the problem of too many texts

Lucene skip table

技术干货|AI框架动静态图统一的思考

Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select

PAT甲级 1028 List Sorting

Lucene introduces NFA

Various postures of CS without online line
随机推荐
C2 several methods of merging VCF files
Go language foundation ----- 11 ----- regular expression
experiment.........
Go language foundation ----- 04 ----- closure, array slice, map, package
Go language foundation ----- 13 ----- file
Industrial resilience
Go language foundation ----- 06 ----- anonymous fields, fields with the same name
Go language foundation ----- 01 ----- go language features
Why is data service the direction of the next generation data center?
Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
Technical dry goods Shengsi mindspire lite1.5 feature release, bringing a new end-to-end AI experience
项目经验分享:实现一个昇思MindSpore 图层 IR 融合优化 pass
Pat grade a 1027 colors in Mars
Industrial resilience
在浏览器输入url后执行什么
Project experience sharing: Based on mindspore, the acoustic model is realized by using dfcnn and CTC loss function
Go language foundation ----- 08 ----- interface
The difference between typescript let and VaR
Vertx's responsive MySQL template
技术干货|昇思MindSpore创新模型EPP-MVSNet-高精高效的三维重建