当前位置:网站首页>[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 ;
}
边栏推荐
- Hnsw introduction and some reference articles in lucene9
- Responsive MySQL of vertx
- Lucene skip table
- Application of pigeon nest principle in Lucene minshouldmatchsumscorer
- C2 several methods of merging VCF files
- Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
- Technical dry goods Shengsi mindspire operator parallel + heterogeneous parallel, enabling 32 card training 242 billion parameter model
- Go language foundation ----- 09 ----- exception handling (error, panic, recover)
- Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
- 什么是定义?什么是声明?它们有何区别?
猜你喜欢
Go language foundation ----- 06 ----- anonymous fields, fields with the same name
Pat class a 1028 list sorting
截图工具Snipaste
Collector in ES (percentile / base)
Unity XR实现交互(抓取,移动旋转,传送,射击)-Pico
HarmonyOS第三次培训笔记
UA camouflage, get and post in requests carry parameters to obtain JSON format content
[MySQL 12] MySQL 8.0.18 reinitialization
Go language foundation ----- 07 ----- method
[mindspire paper presentation] summary of training skills in AAAI long tail problem
随机推荐
Robots protocol
[at] abc 258G - Triangle 三元组可达-暴力
项目经验分享:实现一个昇思MindSpore 图层 IR 融合优化 pass
Go language foundation ----- 09 ----- exception handling (error, panic, recover)
哪一刻你才发现青春结束了
截图工具Snipaste
华为S5700交换机初始化和配置telnet,ssh用户方法
Mail sending of vertx
Vertx metric Prometheus monitoring indicators
C2-关于VCF文件合并的几种方法
Analysis of the problems of the 11th Blue Bridge Cup single chip microcomputer provincial competition
项目经验分享:基于昇思MindSpore,使用DFCNN和CTC损失函数的声学模型实现
优质博客——
Lucene skip table
Go language foundation ----- 08 ----- interface
PAT甲级 1029 Median
Go language foundation ----- 05 ----- structure
What did the DFS phase do
Technical dry goods Shengsi mindspire operator parallel + heterogeneous parallel, enabling 32 card training 242 billion parameter model
List exercises after class