2007-2008 Winter Petrozavodsk Camp, Andrew Stankevich Contest 28 (ASC 28)J. Triatrip(bitset优化)

https://codeforc.es/gym/100342

bitset存边搞一搞

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int N=2e3+5;
 5 bitset<N>in[N],out[N],t;
 6 char s[N][N];
 7 int n;
 8 int main(){
 9     freopen("triatrip.in","r",stdin);//没这两行就wa 服了
10     freopen("triatrip.out","w",stdout);
11     scanf("%d",&n);
12     for(int i=1;i<=n;i++){
13         scanf("%s",s[i]+1);
14     }
15     for(int i=1;i<=n;i++){
16         for(int j=1;j<=n;j++){
17             if(s[i][j]==‘+‘){
18                 in[i][j]=1;
19                 out[j][i]=1;
20             }
21         }
22     }
23     ll ans=0;
24     for(int i=1;i<=n;i++){
25         for(int j=1;j<=n;j++){
26             if(s[i][j]==‘+‘){
27                 t=(in[j])&(out[i]);
28                 ans+=t.count();
29             }
30         }
31     }
32     cout<<ans/3<<endl;
33 }

 

2007-2008 Winter Petrozavodsk Camp, Andrew Stankevich Contest 28 (ASC 28)J. Triatrip(bitset优化)

上一篇:iOS 隐藏状态栏


下一篇:win10系统详细安装教程一