当前位置:网站首页>[at] ABC 258g - Triangle triples reachable - violence
[at] ABC 258g - Triangle triples reachable - violence
2022-07-03 07:45:00 【*DDL_ GzmBlog】
Preface
t a g : tag : tag:bitset01 chart
Portal :
The question :
Given a 01 01 01 Complete graph , 1 1 1 Indicates that these two points are connected by edges , 0 0 0 It means that these two points have no edge connected
Ask how many groups of triples there are ( i , j , k ) (i,j,k) (i,j,k), Meet the requirement that two sides are connected
Ideas :
Violent practices n 3 n^3 n3, Because graphs only exist 01 01 01, We consider using bit operations to subtract one level of enumeration
namely bitset , We store the status in biset in , Then enumerate the states between the two lines , Conduct & \& & operation
Obviously, if & = 1 \&=1 &=1 that , There are three points that can be reached , Time complexity 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 ;
}
边栏推荐
- Hnsw introduction and some reference articles in lucene9
- Mail sending of vertx
- Technical dry goods | Bert model for the migration of mindspore NLP model - text matching task (2): training and evaluation
- 研究显示乳腺癌细胞更容易在患者睡觉时进入血液
- Go language foundation ----- 16 ----- goroutine, GPM model
- experiment.........
- PAT甲级 1029 Median
- The concept of C language pointer
- Go language foundation ----- 04 ----- closure, array slice, map, package
- Epoll related references
猜你喜欢

【LeetCode】4. Best Time to Buy and Sell Stock·股票买卖最佳时机

Shengsi mindspire is upgraded again, the ultimate innovation of deep scientific computing

Usage of requests module

截图工具Snipaste

The concept of C language pointer

【LeetCode】4. Best time to buy and sell stock
![[mindspire paper presentation] summary of training skills in AAAI long tail problem](/img/34/9c9ec1b94edeecd4a3e7f20fdd8356.png)
[mindspire paper presentation] summary of training skills in AAAI long tail problem

研究显示乳腺癌细胞更容易在患者睡觉时进入血液

Go language foundation ----- 07 ----- method

PAT甲级 1027 Colors in Mars
随机推荐
Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
HCIA notes
华为交换机配置ssh登录远程管理交换机
技术干货|关于AI Architecture未来的一些思考
PAT甲级 1032 Sharing
HDMI2.1与HDMI2.0的区别以及转换PD信号。
The concept of C language pointer
Pat grade a 1027 colors in Mars
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
PAT甲级 1028 List Sorting
Go language foundation ----- 08 ----- interface
GoLang之结构体
Go language foundation ------ 12 ------ JSON
Go language foundation ----- 11 ----- regular expression
OSPF experiment
输入三次猜一个数字
Robots protocol
微软安全响应中心
【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结
Lucene introduces NFA