Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- namespace CodeCup
- {
- class Program
- {
- static bool Check(string[][] x)
- {
- var result = false;
- foreach (var i in x)
- {
- foreach (var i2 in i)
- {
- if (i2 == "0")
- result = true;
- }
- }
- int n = x.Length;
- for (int j = 0; j < n -1; j++ )
- for (int j2 = 0; j2 < n - 1; j2++)
- {
- if (
- x[j][j2] == x[j+1][j2]
- ||
- x[j][j2] == x[j ][j2 + 1]
- )
- {
- result = true;
- }
- }
- return result;
- }
- static void Main(string[] args)
- {
- string filename;
- if (args.Length > 0 )
- filename = args[0];
- // закомментить
- filename = "input.txt";
- string outputFilename = filename + ".a";
- int t;
- int n;
- List<string> answers = new List<string>();
- using (StreamReader reader = new StreamReader(filename))
- {
- string line;
- line = reader.ReadLine();
- t = int.Parse(line);
- for (int i = 0; i < t; i++)
- {
- line = reader.ReadLine();
- n = int.Parse(line);
- string[][] x = new string [n][];
- for (int i2 = 0; i2 < n; i2++)
- {
- line = reader.ReadLine();
- x[i2] = line.Split(new Char[] {' '});
- //Console.WriteLine(string.Join(",", x[i2]));
- }
- answers.Add(Check(x) ? "YES" : "NO");
- //Console.WriteLine(Check(x) ? "YES" : "NO");
- }
- }
- File.WriteAllLines(outputFilename, answers);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement