Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- StreamReader inpFile = new StreamReader("input.txt");
- StreamWriter outpFile = new StreamWriter("output.txt");
- var nString = inpFile.ReadLine().Split(' ');
- int n = int.Parse(nString[0]);
- int m = int.Parse(nString[1]);
- int[,] data = new int[m, n + 1];
- bool[] nots = new bool[n];
- bool[] t = new bool[n];
- int[] s = new int[n];
- int c = 0, q = 0, z = 0;
- for (int i = 0; i < m; i++) {
- var str = inpFile.ReadLine().Split(' ');
- for (int j = 0; j <= n; j++) {
- data[i, j] = int.Parse(str[j]);
- }
- for (int j = 0; j < n; j++){
- if (data[i, j] == 1 && data[i, n] == 0 && !nots[j]) {
- nots[j] = true;
- c++;
- }
- }
- }
- for (int i = 0; i < m; i++) {
- var count = 0;
- if (data[i, n] == 0)
- continue;
- for (int j = 0; j < n; j++) {
- if (data[i, j] == 1 && !nots[j]) {
- count++;
- q = j;
- }
- }
- if (count == 0) {
- outpFile.Write("Incorrect");
- outpFile.Flush();
- return;
- }
- if (count == 1 && !t[q]) {
- t[q] = true;
- z++;
- }
- }
- outpFile.Write("{0} ", c);
- for (int i = 0; i < n; i++) {
- if (nots[i])
- outpFile.Write("{0} ", i + 1);
- }
- outpFile.WriteLine();
- outpFile.Write("{0} ", z);
- for (int i = 0; i < n; i++) {
- if (t[i])
- outpFile.Write("{0} ", i + 1);
- }
- outpFile.WriteLine();
- outpFile.Write("{0} ", n - z - c);
- for (int i = 0; i < n; i++) {
- if (!nots[i] && !t[i])
- outpFile.Write("{0} ", i + 1);
- }
- outpFile.Flush();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement