当前位置:网站首页>[at] ABC 258g - triple Reach - violence
[at] ABC 258g - triple Reach - violence
2022-07-03 07:44:00 【* DDL Gzmblog】
Préface
t a g : tag : tag:bitset01Fig.
Porte de transfert:
Titre :
Compte tenu d'un 01 01 01Graphique complet, 1 1 1Cela signifie que les deux points ont des bords reliés, 0 0 0Ça veut dire qu'il n'y a pas de bords reliant ces deux points
Demandez combien de triples il y a ( i , j , k ) (i,j,k) (i,j,k),Il y a des bords qui relient les deux
Idées :
Pratiques violentes n 3 n^3 n3,Parce que le graphique n'existe que 01 01 01,Nous envisageons d'utiliser des opérations de bits moins une couche d'énumération
C'est - à - dire:bitset , Nous mettons l'état dansbisetMoyenne,Puis énumérez les états entre les deux lignes,En cours & \& &Opération
Apparemment, si & = 1 \&=1 &=1Alors,Trois points sont accessibles,Complexité temporelle 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 ;
}
边栏推荐
- Go language foundation ----- 15 ----- reflection
- 技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务
- Lucene hnsw merge optimization
- Traversal in Lucene
- 技术干货|百行代码写BERT,昇思MindSpore能力大赏
- PAT甲级 1032 Sharing
- Epoll related references
- Leetcode 213: looting II
- 项目经验分享:基于昇思MindSpore,使用DFCNN和CTC损失函数的声学模型实现
- Technical dry goods | hundred lines of code to write Bert, Shengsi mindspire ability reward
猜你喜欢

PAT甲级 1027 Colors in Mars

技术干货|昇思MindSpore NLP模型迁移之Roberta ——情感分析任务

OSPF experiment

HCIA notes

Pat class a 1030 travel plan

Go language foundation ----- 09 ----- exception handling (error, panic, recover)

Go language foundation ----- 08 ----- interface

【MySQL 14】使用DBeaver工具远程备份及恢复MySQL数据库(Linux 环境)

Go language foundation ------ 12 ------ JSON

Pat class a 1031 Hello world for u
随机推荐
微软安全响应中心
Go language foundation ----- 04 ----- closure, array slice, map, package
Lucene hnsw merge optimization
Pat grade a 1029 median
static关键字
Vertx's responsive redis client
JUnit unit test of vertx
EtherCAT state machine transition (ESM)
Technical dry goods Shengsi mindspire innovation model EPP mvsnet high-precision and efficient 3D reconstruction
Unified handling and interception of exception exceptions of vertx
yarn link 是如何帮助开发者对 NPM 包进行 debug 的?
The babbage industrial policy forum
Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
Go language foundation ------ 14 ------ gotest
Epoll related references
Project experience sharing: Based on mindspore, the acoustic model is realized by using dfcnn and CTC loss function
Vertx multi vertical shared data
Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
s7700设备如何清除console密码
【LeetCode】2. Valid Parentheses·有效的括号