Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int x;
- scanf("%d", &x);
- vector<int> A,B,C,D,E,F;
- int soma=0;
- for(int a=0; a<4*x; a++){
- int m;
- scanf("%d", &m);
- if(a%4==0){
- A.push_back(m);
- }
- else if(a%4==1){
- B.push_back(m);
- }
- else if(a%4==2){
- C.push_back(m);
- }
- else if(a%4==3){
- D.push_back(m);
- }
- }
- for(int b=0; b<x; b++){
- for(int c=0; c<x;c++){
- E.push_back(A[b]+B[c]);
- }
- }
- for(int d=0; d<x; d++){
- for(int e=0; e<x; e++){
- F.push_back(C[d]+D[e]);
- }
- }
- while(1){
- int ok=0;
- for(int f=0; f<x*x-1; f++){
- if(E[f]>E[f+1]){swap(E[f],E[f+1]); ok=1;}
- if (ok=0) break;
- }
- }
- while(1){
- int ok=0;
- for(int g=0; g<x*x-1; g++){
- if(F[g]>F[g+1]){swap(F[g],F[g+1]); ok=1;}
- if (ok=0) break;
- }
- }
- for(int m=0; m<x*x; m++){
- for(int n=0; n<x*x; n++){
- if(binary_search(F.begin(), F.end(), -E[m])){
- soma += lower_bound(F.begin(), F.end(), -E[m]) - upper_bound(F.begin(), F.end(), -E[m]);
- }
- }
- }
- printf("%d\n", soma);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement