Submission #1623017


Source Code Expand

Copy

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int row = sc.nextInt();
		int colomn = sc.nextInt();
		int target = sc.nextInt();
		int[][] originalTable = new int[row][colomn];
		for(int i = 0; i < row; i++) {
			for(int j = 0; j < colomn; j++) {
				originalTable[i][j] = 0;
			}
		}
		String answer = "No";
		outside: for(int changeRowNum = 0; changeRowNum <= row; changeRowNum++) {
			for(int changeColumnNum = 0; changeColumnNum <= colomn; changeColumnNum++) {
				int[][] table = originalTable;
				int rowNum = 0;
				int columnNum = 0;
				while(rowNum < changeRowNum || columnNum < changeColumnNum) {
					if(rowNum < changeRowNum) {
						table = pushButton(true, rowNum, table);
						rowNum++;
					}
					if(columnNum < changeColumnNum) {
						table = pushButton(false, columnNum, table);
						columnNum++;
					}
				}
				int count = 0;
				for(int[] i: table) {
					for(int j: i) {
						if(j == 1) {
							count++;
						}
					}
				}
				if(count == target) {
					answer = "Yes";
					break outside;
				}
			}
		}
		System.out.println(answer);

	}
	public static int[][] pushButton(boolean isRow, int buttonNo, int[][] originalTable) {
		int rowNo = originalTable.length;
		int columnNo = originalTable[0].length;
		int[][] table = new int[rowNo][columnNo];
		for(int i = 0; i < rowNo; i++) {
			for(int j = 0; j < columnNo; j++) {
				table[i][j] = originalTable[i][j];
			}
		}
		if(isRow) {
			for(int i = 0; i < columnNo; i++) {
				table[buttonNo][i] = change0_1(table[buttonNo][i]);
			}
		} else {
			for(int i = 0; i < rowNo; i++) {
				table[i][buttonNo] = change0_1(table[i][buttonNo]);
			}
		}
		return table;
	}
	public static int change0_1(int num) {
		if(num == 0) {
			num = 1;
		} else {
			num = 0;
		}
		return num;
	}

}

Submission Info

Submission Time
Task A - Snuke's favorite YAKINIKU
User taichii
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 1931 Byte
Status RE
Exec Time 110 ms
Memory 23892 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
RE × 3
RE × 16
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt RE 110 ms 22100 KB
02.txt RE 91 ms 18768 KB
03.txt RE 91 ms 23892 KB
04.txt RE 91 ms 21716 KB
05.txt RE 91 ms 19412 KB
06.txt RE 91 ms 19796 KB
07.txt RE 91 ms 20052 KB
08.txt RE 90 ms 19796 KB
09.txt RE 96 ms 18644 KB
10.txt RE 91 ms 18640 KB
11.txt RE 91 ms 19412 KB
12.txt RE 90 ms 20692 KB
13.txt RE 92 ms 21588 KB
s1.txt RE 91 ms 19668 KB
s2.txt RE 91 ms 23764 KB
s3.txt RE 95 ms 19796 KB