Guest User

Untitled

a guest
May 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. bool M[5001][5001];
  6. int n,m;
  7.  
  8. int main(){
  9.     cin>>n>>m;
  10.     for (int i=0;i<m;i++){
  11.         int a,b;
  12.         cin>>a>>b;
  13.         a--;b--;
  14.         M[a][b]=1;
  15.         M[b][a]=1;
  16.     }
  17.     int answer=n+(n*(n-1))/2-m;
  18.     int answer_three=0; int answer_four=0;
  19.     cout<<"THREE ANSWER:"<<endl;
  20.     for (int i=0;i<n;i++)
  21.     for (int j=i+1;j<n;j++)
  22.     for (int z=j+1;z<n;z++){
  23.         if (!(M[i][j] || M[i][z] || M[j][z])){
  24.             answer++,answer_three++;
  25.             cout<<i<<" "<<j<<" "<<z<<endl;
  26.         }
  27.     }
  28.     cout<<"FOURTH ANSWER::"<<endl;
  29.     for (int i=0;i<n;i++)
  30.     for (int j=i+1;j<n;j++)
  31.     for (int z=j+1;z<n;z++)
  32.     for (int u=z+1;u<n;u++){
  33.         if (!(M[i][j] || M[i][z] || M[i][u] || M[j][z] || M[j][u] || M[z][u])){
  34.             answer++,answer_four++;
  35.             cout<<i<<" "<<j<<" "<<z<<" "<<u<<endl;
  36.         }
  37.     }
  38.     cout<<"REAL ANSWER:"<<endl;
  39.     cout<<answer_three<<" "<<answer_four<<endl;
  40.     cout<<answer<<endl;
  41.     return 0;
  42. }
Add Comment
Please, Sign In to add comment