Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, const char * argv[]) {
  7.     freopen("disease.in", "r", stdin);
  8.     freopen("disease.out", "w", stdout);
  9.    
  10.     int n, m;
  11.     cin >> n >> m;
  12.     int analysis[m][n];
  13.     int results[m];
  14.     int position[n];
  15.    
  16.     for(int x = 0; x < m; ++x) {
  17.         for(int y = 0; y < n; ++y)
  18.             cin >> analysis[x][y];
  19.         cin >> results[x];
  20.     }
  21.     for(int y = 0; y < n; ++y) {
  22.         position[y] = 3;
  23.         for(int x = 0; x < m; ++x)
  24.             if((analysis[x][y] == 1) && (results[x] == 0)) {
  25.                 position[y] = 1; break;
  26.             }
  27.     }
  28.    
  29.     int count = 0; int pos = 0;
  30.     for(int x = 0; x < m; ++x)
  31.         if(results[x] == 1) {
  32.             count = 0;
  33.             for(int y = 0; y < n; ++y)
  34.                 if((analysis[x][y] == 1) && (position[y] != 1)) {
  35.                     count += 1;
  36.                     pos = y;
  37.                     if(count > 1) break;
  38.             }
  39.             if(count == 0) {
  40.                 cout << "Incorrect";
  41.                 exit(0);
  42.             }
  43.             else if(count == 1)
  44.                 position[pos] = 2;
  45.     }
  46.    
  47.     int one = 0; int two = 0; int three = 0;
  48.    
  49.     for(int y = 0; y < n; ++y)
  50.         if(position[y] == 1)
  51.             ++one;
  52.             else if(position[y] == 2)
  53.                 ++two;
  54.                 else
  55.                     ++three;
  56.    
  57.     cout << one << " ";
  58.     for(int y = 0; y < n; ++y)
  59.         if(position[y] == 1)
  60.             cout << y + 1 << " ";
  61.     cout << endl;
  62.     cout << two << " ";
  63.     for(int y = 0; y < n; ++y)
  64.         if(position[y] == 2)
  65.             cout << y + 1 << " ";
  66.     cout << endl;
  67.     cout << three << " ";
  68.     for(int y = 0; y < n; ++y)
  69.         if(position[y] == 3)
  70.             cout << y + 1 << " ";
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement