当前位置:网站首页>[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:bitset
01 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 ;
}
边栏推荐
- What did the DFS phase do
- Lucene skip table
- 基于RNA的新型癌症疗法介绍
- Responsive MySQL of vertx
- Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction
- 华为交换机基础配置(telnet/ssh登录)
- 【MySQL 14】使用DBeaver工具远程备份及恢复MySQL数据库(Linux 环境)
- Precautions for opensips and TLS SIP trunk docking
- EtherCAT state machine transition (ESM)
- Technology dry goods | luxe model for the migration of mindspore NLP model -- reading comprehension task
猜你喜欢
【MySQL 11】怎么解决MySQL 8.0.18 大小写敏感问题
Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire
Pat class a 1032 sharing
【MySQL 12】MySQL 8.0.18 重新初始化
Go language foundation ----- 08 ----- interface
在浏览器输入url后执行什么
【LeetCode】4. Best time to buy and sell stock
技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
技术干货|关于AI Architecture未来的一些思考
【CoppeliaSim4.3】C#调用 remoteApi控制场景中UR5
随机推荐
Traversal in Lucene
【MySQL 14】使用DBeaver工具远程备份及恢复MySQL数据库(Linux 环境)
Research shows that breast cancer cells are more likely to enter the blood when patients sleep
Analysis of the eighth Blue Bridge Cup single chip microcomputer provincial competition
OSPF experiment
Go language foundation ------ 14 ------ gotest
opensips与对方tls sip trunk对接注意事项
技术干货 | AlphaFold/ RoseTTAFold开源复现(2)—AlphaFold流程分析和训练构建
Introduction of novel RNA based cancer therapies
HarmonyOS第三次培训笔记
华为交换机:配置telnet和ssh、web访问
【LeetCode】3. Merge two sorted lists · merge two ordered linked lists
HCIA notes
IndexSort
昇思MindSpore再升级,深度科学计算的极致创新
Go language foundation ----- 02 ----- basic data types and operators
项目经验分享:基于昇思MindSpore,使用DFCNN和CTC损失函数的声学模型实现
Unified handling and interception of exception exceptions of vertx
Go language foundation ------ 12 ------ JSON
GoLang之结构体