Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main(int argc, const char * argv[]) {
- freopen("disease.in", "r", stdin);
- freopen("disease.out", "w", stdout);
- int n, m;
- cin >> n >> m;
- int analysis[m][n];
- int results[m];
- int position[n];
- for(int x = 0; x < m; ++x) {
- for(int y = 0; y < n; ++y)
- cin >> analysis[x][y];
- cin >> results[x];
- }
- for(int y = 0; y < n; ++y) {
- position[y] = 3;
- for(int x = 0; x < m; ++x)
- if((analysis[x][y] == 1) && (results[x] == 0)) {
- position[y] = 1; break;
- }
- }
- int count = 0; int pos = 0;
- for(int x = 0; x < m; ++x)
- if(results[x] == 1) {
- count = 0;
- for(int y = 0; y < n; ++y)
- if((analysis[x][y] == 1) && (position[y] != 1)) {
- count += 1;
- pos = y;
- if(count > 1) break;
- }
- if(count == 0) {
- cout << "Incorrect";
- exit(0);
- }
- else if(count == 1)
- position[pos] = 2;
- }
- int one = 0; int two = 0; int three = 0;
- for(int y = 0; y < n; ++y)
- if(position[y] == 1)
- ++one;
- else if(position[y] == 2)
- ++two;
- else
- ++three;
- cout << one << " ";
- for(int y = 0; y < n; ++y)
- if(position[y] == 1)
- cout << y + 1 << " ";
- cout << endl;
- cout << two << " ";
- for(int y = 0; y < n; ++y)
- if(position[y] == 2)
- cout << y + 1 << " ";
- cout << endl;
- cout << three << " ";
- for(int y = 0; y < n; ++y)
- if(position[y] == 3)
- cout << y + 1 << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement