当前位置:网站首页>[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 ;
}
边栏推荐
- Usage of requests module
- Go language foundation ------ 12 ------ JSON
- PAT甲级 1027 Colors in Mars
- Analysis of the problems of the 11th Blue Bridge Cup single chip microcomputer provincial competition
- 基于RNA的新型癌症疗法介绍
- 华为交换机:配置telnet和ssh、web访问
- Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction
- Chapter VI - Containers
- Paper learning -- Study on the similarity of water level time series of Xingzi station in Poyang Lake
- Go language foundation ----- 09 ----- exception handling (error, panic, recover)
猜你喜欢

技术干货|关于AI Architecture未来的一些思考

Pat class a 1030 travel plan

HarmonyOS第三次培训笔记

Hnsw introduction and some reference articles in lucene9

Go language foundation ----- 05 ----- structure

技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer

Collector in ES (percentile / base)

截图工具Snipaste

技术干货 | AlphaFold/ RoseTTAFold开源复现(2)—AlphaFold流程分析和训练构建

Go language foundation ----- 03 ----- process control, function, value transfer, reference transfer, defer function
随机推荐
Pat grade a 1027 colors in Mars
Research shows that breast cancer cells are more likely to enter the blood when patients sleep
Harmonyos third training notes
C2 several methods of merging VCF files
Pat grade a 1029 median
HDMI2.1与HDMI2.0的区别以及转换PD信号。
What did the DFS phase do
项目经验分享:实现一个昇思MindSpore 图层 IR 融合优化 pass
Unified handling and interception of exception exceptions of vertx
Vertx multi vertical shared data
[MySQL 11] how to solve the case sensitive problem of MySQL 8.0.18
在浏览器输入url后执行什么
experiment.........
UA camouflage, get and post in requests carry parameters to obtain JSON format content
opensips与对方tls sip trunk对接注意事项
Go language foundation ------ 14 ------ gotest
GoLang之结构体
技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
项目经验分享:基于昇思MindSpore,使用DFCNN和CTC损失函数的声学模型实现
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具