Kaidul

SUMFOUR

Feb 11th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define Max 4001
  5. map <int, bool> rest;
  6. int main(void) {
  7. #ifndef ONLINE_JUDGE
  8.     freopen("input.txt", "r", stdin);
  9. #endif
  10.     int n;
  11.     int a, b, c, d;
  12.     vector <int> A, B, C, D;
  13.     while( ~scanf("%d", &n) ) {
  14.         for(int i = 0; i < n; ++i) {
  15.             scanf("%d %d %d %d", &a, &b, &c, &d);
  16.             A.push_back(a);
  17.             B.push_back(b);
  18.             C.push_back(c);
  19.             D.push_back(d);
  20.         }
  21.         for(int i = 0; i < n; ++i) {
  22.             for(int j = 0; j < n; ++j) {
  23.                 rest[ A[i] + B[j] ] = true;
  24.             }
  25.         }
  26.         int count = 0;
  27.         for(int i = 0; i < n; ++i) {
  28.             for(int j = 0; j < n; ++j) {
  29.                 if( rest[-(C[i] + D[j])] )
  30.                     ++count;
  31.             }
  32.         }
  33.         printf("%d\n", count);
  34.         A.clear();
  35.         B.clear();
  36.         C.clear();
  37.         D.clear();
  38.         rest = map <int, bool> ();
  39.     }
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment