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

2021-02-04 15:13

阅读:760

标签:name   ==   type   include   typedef   stdin   bsp   href   namespace   

https://codeforc.es/gym/100342

bitset存边搞一搞

 1 #include 2 using namespace std;
 3 typedef long long ll;
 4 const int N=2e3+5;
 5 bitsetin[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){
13         scanf("%s",s[i]+1);
14     }
15     for(int i=1;i){
16         for(int j=1;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){
25         for(int j=1;j){
26             if(s[i][j]==‘+‘){
27                 t=(in[j])&(out[i]);
28                 ans+=t.count();
29             }
30         }
31     }
32     coutendl;
33 }

 

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

标签:name   ==   type   include   typedef   stdin   bsp   href   namespace   

原文地址:https://www.cnblogs.com/ccsu-kid/p/11470268.html


评论


亲,登录后才可以留言!