当前位置:网站首页>[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 ;
}
边栏推荐
- Lucene hnsw merge optimization
- PAT甲级 1032 Sharing
- Traversal in Lucene
- 图像识别与检测--笔记
- [coppeliasim4.3] C calls UR5 in the remoteapi control scenario
- Technology dry goods | luxe model for the migration of mindspore NLP model -- reading comprehension task
- Go language foundation ----- 16 ----- goroutine, GPM model
- PAT甲级 1029 Median
- PDO and SDO concepts
- IndexSort
猜你喜欢

Hnsw introduction and some reference articles in lucene9

Harmonyos third training notes

Leetcode 198: house raiding
![[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

Robots protocol

【LeetCode】2. Valid Parentheses·有效的括号

PAT甲级 1031 Hello World for U

Technical dry goods Shengsi mindspire lite1.5 feature release, bringing a new end-to-end AI experience

Technical dry goods Shengsi mindspire innovation model EPP mvsnet high-precision and efficient 3D reconstruction

Go language foundation ----- 16 ----- goroutine, GPM model
随机推荐
Chapter VI - Containers
Application of pigeon nest principle in Lucene minshouldmatchsumscorer
Go language foundation ----- 10 ----- string related operations (operation function, string conversion)
技术干货|昇思MindSpore NLP模型迁移之Bert模型—文本匹配任务(二):训练和评估
opensips与对方tls sip trunk对接注意事项
Hnsw introduction and some reference articles in lucene9
密西根大学张阳教授受聘中国上海交通大学客座教授(图)
Go language foundation ----- 06 ----- anonymous fields, fields with the same name
Lucene introduces NFA
华为交换机Console密码重置、设备初始化、默认密码
【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结
哪一刻你才发现青春结束了
Usage of requests module
Paper learning -- Study on the similarity of water level time series of Xingzi station in Poyang Lake
【踩坑系列】mysql 修改root密码失败
Pgadmin 4 v6.11 release, PostgreSQL open source graphical management tool
HCIA notes
Collector in ES (percentile / base)
PAT甲级 1032 Sharing
Vertx metric Prometheus monitoring indicators