fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. #define F first
  7. #define S second
  8. #define pb push_back
  9. #define mp make_pair
  10. #define endl "\n"
  11. typedef long long ll;
  12. typedef long double ld;
  13. const int mod = 1000000007;
  14.  
  15. int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
  16. int ncr(int n,int r){int res=1;if(r>n-r)r=n-r;for(int i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
  17. int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
  18. int lcm(int a,int b){return (a/gcd(a,b)*b);}
  19. int max(int a,int b){int ans=a>b?a:b;return ans;}
  20. int min(int a,int b){int ans=a<b?a:b;return ans;}
  21. //cout<<fixed<<setprecision(8)<<x<<endl;
  22. clock_t time_p=clock();
  23. void rtime(){time_p=clock()-time_p;cerr<<"******************\nTime taken : "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";}
  24.  
  25.  
  26. int main()
  27. {
  28. freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
  29. //fast;
  30. //int t=1; cin>>t; while(t--)
  31. {
  32. int n,m,A,B,C;
  33. cin>>n>>m;
  34. int a[n][m];
  35. for(int i=0;i<n;i++)
  36. {
  37. for(int j=0;j<m;j++)
  38. cin>>a[i][j];
  39. }
  40. cin>>A>>B>>C;
  41.  
  42. int ra[n]={0},ca[m]={0};
  43. for(int i=0;i<n;i++)
  44. {
  45. int c=0;
  46. for(int j=0;j<m;j++)
  47. c+=a[i][j];
  48. ra[i]=c;
  49. }
  50. for(int i=0;i<m;i++)
  51. {
  52. int c=0;
  53. for(int j=0;j<n;j++)
  54. c+=a[j][i];
  55. ca[i]=c;
  56. }
  57.  
  58. for(int i=1;i<n;i++)
  59. ra[i]+=ra[i-1];
  60. for(int i=1;i<m;i++)
  61. ca[i]+=ca[i-1];
  62.  
  63. if(ca[m-1]!=A+B+C)
  64. return cout<<0,0;
  65. vector<int> x{A,B,C};
  66. sort(x.begin(),x.end());
  67. int ans=0;
  68. do{
  69. map<int,int> mr,mc;
  70. for(int i=0;i<n-1;i++)
  71. {
  72. if(ra[i]==x[0]+x[1])
  73. ans+=mr[x[0]];
  74. mr[ra[i]]++;
  75. }
  76. for(int i=0;i<m-1;i++)
  77. {
  78. if(ca[i]==x[0]+x[1])
  79. {
  80. ans+=mc[x[0]];
  81. }
  82. mc[ca[i]]++;
  83. }
  84.  
  85. }while(next_permutation(x.begin(),x.end()));
  86. cout<<ans;
  87. }
  88. // rtime();
  89. return 0;
  90. }
  91.  
Compilation error #stdin compilation error #stdout 0s 15240KB
stdin
2 5
1 1 1 1 1
2 2 2 2 2
3 6 6
compilation info
prog.cpp:26:10: error: ‘::main’ must return ‘int’
 int main()
          ^
stdout
Standard output is empty