UVALive 6500 Boxes
Boxes
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int T,m,n; 6 int i,j,s; 7 int a[105][105]; 8 scanf("%d",&T); 9 while(T--) 10 { 11 s=0; 12 scanf("%d %d",&m,&n); 13 for(i=1;i<=m;i++) 14 { 15 for(j=1;j<=n;j++) 16 scanf("%d",&a[i][j]); 17 } 18 for(j=1;j<=n;j++) 19 { 20 int x=0; 21 for(i=m;i>=1;i--) 22 { 23 if(a[i][j]==1) 24 { 25 s=s+m-i-x; 26 x++; 27 } 28 } 29 } 30 printf("%d\n",s); 31 } 32 return 0; 33 }