Submission #1360815
Source Code Expand
import java.awt.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;
import static java.lang.Math.max;
import static java.lang.Math.min;
public class Main implements Runnable{
// SOLUTION!!!
// HACK ME PLEASE IF YOU CAN!!!
// PLEASE!!!
// PLEASE!!!
// PLEASE!!!
private final static Random rnd = new Random();
private final static String fileName = "";
private void solve() {
int n = readInt();
int m = readInt();
int h = readInt();
int w = readInt();
int[][] a = can(n, m, h, w);
if (null == a) {
out.println("No");
} else {
out.println("Yes");
for (int[] row : a) {
for (int value : row) out.print(value + " ");
out.println();
}
}
}
int[][] can(int n, int m, int h, int w) {
int[][] a = new int[n][m];
for (int[] row : a) Arrays.fill(row, 1);
for (int i = h - 1; i < n; i += h) {
for (int j = w - 1; j < m; j += w) {
a[i][j] = -(h * w);
}
}
long sum = 0;
for (int[] row : a) sum += getSum(row);
if (sum <= 0) return null;
return a;
}
/////////////////////////////////////////////////////////////////////
private final static boolean FIRST_INPUT_STRING = false;
private final static boolean MULTIPLE_TESTS = true;
private final boolean ONLINE_JUDGE = !new File("input.txt").exists();
private final static int MAX_STACK_SIZE = 128;
private final static boolean OPTIMIZE_READ_NUMBERS = false;
/////////////////////////////////////////////////////////////////////
public void run(){
try{
timeInit();
Locale.setDefault(Locale.US);
init();
if (ONLINE_JUDGE) {
solve();
} else {
do {
try {
timeInit();
solve();
time();
out.println();
} catch (NumberFormatException e) {
break;
} catch (NullPointerException e) {
if (FIRST_INPUT_STRING) break;
else throw e;
}
} while (MULTIPLE_TESTS);
}
out.close();
time();
}catch (Exception e){
e.printStackTrace(System.err);
System.exit(-1);
}
}
/////////////////////////////////////////////////////////////////////
private BufferedReader in;
private OutputWriter out;
private StringTokenizer tok = new StringTokenizer("");
public static void main(String[] args){
new Thread(null, new Main(), "", MAX_STACK_SIZE * (1L << 20)).start();
}
/////////////////////////////////////////////////////////////////////
private void init() throws FileNotFoundException{
Locale.setDefault(Locale.US);
if (ONLINE_JUDGE){
if (fileName.isEmpty()) {
in = new BufferedReader(new InputStreamReader(System.in));
out = new OutputWriter(System.out);
} else {
in = new BufferedReader(new FileReader(fileName + ".in"));
out = new OutputWriter(fileName + ".out");
}
}else{
in = new BufferedReader(new FileReader("input.txt"));
out = new OutputWriter("output.txt");
}
}
////////////////////////////////////////////////////////////////
private long timeBegin;
private void timeInit() {
this.timeBegin = System.currentTimeMillis();
}
private void time(){
long timeEnd = System.currentTimeMillis();
System.err.println("Time = " + (timeEnd - timeBegin));
}
private void debug(Object... objects){
if (ONLINE_JUDGE){
for (Object o: objects){
System.err.println(o.toString());
}
}
}
/////////////////////////////////////////////////////////////////////
private String delim = " ";
private String readLine() {
try {
return in.readLine();
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
private String readString() {
try {
while(!tok.hasMoreTokens()){
tok = new StringTokenizer(readLine());
}
return tok.nextToken(delim);
} catch (NullPointerException e) {
return null;
}
}
/////////////////////////////////////////////////////////////////
private final char NOT_A_SYMBOL = '\0';
private char readChar() {
try {
int intValue = in.read();
if (intValue == -1){
return NOT_A_SYMBOL;
}
return (char) intValue;
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
private char[] readCharArray() {
return readLine().toCharArray();
}
private char[][] readCharField(int rowsCount) {
char[][] field = new char[rowsCount][];
for (int row = 0; row < rowsCount; ++row) {
field[row] = readCharArray();
}
return field;
}
/////////////////////////////////////////////////////////////////
private long optimizedReadLong() {
int sign = 1;
long result = 0;
boolean started = false;
while (true) {
try {
int j = in.read();
if (-1 == j) {
if (started) return sign * result;
throw new NumberFormatException();
}
if (j == '-') {
if (started) throw new NumberFormatException();
sign = -sign;
}
if ('0' <= j && j <= '9') {
result = result * 10 + j - '0';
started = true;
} else if (started) {
return sign * result;
}
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
}
private int readInt() {
if (!OPTIMIZE_READ_NUMBERS) {
return Integer.parseInt(readString());
} else {
return (int) optimizedReadLong();
}
}
private int[] readIntArray(int size) {
int[] array = new int[size];
for (int index = 0; index < size; ++index){
array[index] = readInt();
}
return array;
}
private int[] readSortedIntArray(int size) {
Integer[] array = new Integer[size];
for (int index = 0; index < size; ++index) {
array[index] = readInt();
}
Arrays.sort(array);
int[] sortedArray = new int[size];
for (int index = 0; index < size; ++index) {
sortedArray[index] = array[index];
}
return sortedArray;
}
private int[] readIntArrayWithDecrease(int size) {
int[] array = readIntArray(size);
for (int i = 0; i < size; ++i) {
array[i]--;
}
return array;
}
///////////////////////////////////////////////////////////////////
private int[][] readIntMatrix(int rowsCount, int columnsCount) {
int[][] matrix = new int[rowsCount][];
for (int rowIndex = 0; rowIndex < rowsCount; ++rowIndex) {
matrix[rowIndex] = readIntArray(columnsCount);
}
return matrix;
}
private int[][] readIntMatrixWithDecrease(int rowsCount, int columnsCount) {
int[][] matrix = new int[rowsCount][];
for (int rowIndex = 0; rowIndex < rowsCount; ++rowIndex) {
matrix[rowIndex] = readIntArrayWithDecrease(columnsCount);
}
return matrix;
}
///////////////////////////////////////////////////////////////////
private long readLong() {
if (!OPTIMIZE_READ_NUMBERS) {
return Long.parseLong(readString());
} else {
return optimizedReadLong();
}
}
private long[] readLongArray(int size) {
long[] array = new long[size];
for (int index = 0; index < size; ++index){
array[index] = readLong();
}
return array;
}
////////////////////////////////////////////////////////////////////
private double readDouble() {
return Double.parseDouble(readString());
}
private double[] readDoubleArray(int size) {
double[] array = new double[size];
for (int index = 0; index < size; ++index){
array[index] = readDouble();
}
return array;
}
////////////////////////////////////////////////////////////////////
private BigInteger readBigInteger() {
return new BigInteger(readString());
}
private BigDecimal readBigDecimal() {
return new BigDecimal(readString());
}
/////////////////////////////////////////////////////////////////////
private Point readPoint() {
int x = readInt();
int y = readInt();
return new Point(x, y);
}
private Point[] readPointArray(int size) {
Point[] array = new Point[size];
for (int index = 0; index < size; ++index){
array[index] = readPoint();
}
return array;
}
/////////////////////////////////////////////////////////////////////
@Deprecated
private List<Integer>[] readGraph(int vertexNumber, int edgeNumber) {
@SuppressWarnings("unchecked")
List<Integer>[] graph = new List[vertexNumber];
for (int index = 0; index < vertexNumber; ++index){
graph[index] = new ArrayList<>();
}
while (edgeNumber-- > 0){
int from = readInt() - 1;
int to = readInt() - 1;
graph[from].add(to);
graph[to].add(from);
}
return graph;
}
private static class GraphBuilder {
final int size;
final List<Integer>[] edges;
static GraphBuilder createInstance(int size) {
List<Integer>[] edges = new List[size];
for (int v = 0; v < size; ++v) {
edges[v] = new ArrayList<>();
}
return new GraphBuilder(edges);
}
private GraphBuilder(List<Integer>[] edges) {
this.size = edges.length;
this.edges = edges;
}
public void addEdge(int from, int to) {
addDirectedEdge(from, to);
addDirectedEdge(to, from);
}
public void addDirectedEdge(int from, int to) {
edges[from].add(to);
}
public int[][] build() {
int[][] graph = new int[size][];
for (int v = 0; v < size; ++v) {
List<Integer> vEdges = edges[v];
graph[v] = castInt(vEdges);
}
return graph;
}
}
/////////////////////////////////////////////////////////////////////
private static class IntIndexPair {
static Comparator<IntIndexPair> increaseComparator = new Comparator<Main.IntIndexPair>() {
@Override
public int compare(Main.IntIndexPair indexPair1, Main.IntIndexPair indexPair2) {
int value1 = indexPair1.value;
int value2 = indexPair2.value;
if (value1 != value2) return value1 - value2;
int index1 = indexPair1.index;
int index2 = indexPair2.index;
return index1 - index2;
}
};
static Comparator<IntIndexPair> decreaseComparator = new Comparator<Main.IntIndexPair>() {
@Override
public int compare(Main.IntIndexPair indexPair1, Main.IntIndexPair indexPair2) {
int value1 = indexPair1.value;
int value2 = indexPair2.value;
if (value1 != value2) return -(value1 - value2);
int index1 = indexPair1.index;
int index2 = indexPair2.index;
return index1 - index2;
}
};
static IntIndexPair[] from(int[] array) {
IntIndexPair[] iip = new IntIndexPair[array.length];
for (int i = 0; i < array.length; ++i) {
iip[i] = new IntIndexPair(array[i], i);
}
return iip;
}
int value, index;
IntIndexPair(int value, int index) {
super();
this.value = value;
this.index = index;
}
int getRealIndex() {
return index + 1;
}
}
private IntIndexPair[] readIntIndexArray(int size) {
IntIndexPair[] array = new IntIndexPair[size];
for (int index = 0; index < size; ++index) {
array[index] = new IntIndexPair(readInt(), index);
}
return array;
}
/////////////////////////////////////////////////////////////////////
private static class OutputWriter extends PrintWriter {
final int DEFAULT_PRECISION = 12;
private int precision;
private String format, formatWithSpace;
{
precision = DEFAULT_PRECISION;
format = createFormat(precision);
formatWithSpace = format + " ";
}
OutputWriter(OutputStream out) {
super(out);
}
OutputWriter(String fileName) throws FileNotFoundException {
super(fileName);
}
int getPrecision() {
return precision;
}
void setPrecision(int precision) {
precision = max(0, precision);
this.precision = precision;
format = createFormat(precision);
formatWithSpace = format + " ";
}
String createFormat(int precision){
return "%." + precision + "f";
}
@Override
public void print(double d){
printf(format, d);
}
void printWithSpace(double d){
printf(formatWithSpace, d);
}
void printAll(double...d){
for (int i = 0; i < d.length - 1; ++i){
printWithSpace(d[i]);
}
print(d[d.length - 1]);
}
@Override
public void println(double d){
printlnAll(d);
}
void printlnAll(double... d){
printAll(d);
println();
}
}
/////////////////////////////////////////////////////////////////////
private static class RuntimeIOException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = -6463830523020118289L;
RuntimeIOException(Throwable cause) {
super(cause);
}
}
/////////////////////////////////////////////////////////////////////
//////////////// Some useful constants and functions ////////////////
/////////////////////////////////////////////////////////////////////
private static final int[][] steps = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
private static final int[][] steps8 = {
{-1, 0}, {1, 0}, {0, -1}, {0, 1},
{-1, -1}, {1, 1}, {1, -1}, {-1, 1}
};
private static boolean checkCell(int row, int rowsCount, int column, int columnsCount) {
return checkIndex(row, rowsCount) && checkIndex(column, columnsCount);
}
private static boolean checkIndex(int index, int lim){
return (0 <= index && index < lim);
}
/////////////////////////////////////////////////////////////////////
private static boolean checkBit(int mask, int bit){
return (mask & (1 << bit)) != 0;
}
private static boolean checkBit(long mask, int bit){
return (mask & (1L << bit)) != 0;
}
/////////////////////////////////////////////////////////////////////
private static long getSum(int[] array) {
long sum = 0;
for (int value: array) {
sum += value;
}
return sum;
}
private static Point getMinMax(int[] array) {
int min = array[0];
int max = array[0];
for (int index = 0, size = array.length; index < size; ++index, ++index) {
int value = array[index];
if (index == size - 1) {
min = min(min, value);
max = max(max, value);
} else {
int otherValue = array[index + 1];
if (value <= otherValue) {
min = min(min, value);
max = max(max, otherValue);
} else {
min = min(min, otherValue);
max = max(max, value);
}
}
}
return new Point(min, max);
}
/////////////////////////////////////////////////////////////////////
private static int[] getPrimes(int n) {
boolean[] used = new boolean[n];
used[0] = used[1] = true;
int size = 0;
for (int i = 2; i < n; ++i) {
if (!used[i]) {
++size;
for (int j = 2 * i; j < n; j += i) {
used[j] = true;
}
}
}
int[] primes = new int[size];
for (int i = 0, cur = 0; i < n; ++i) {
if (!used[i]) {
primes[cur++] = i;
}
}
return primes;
}
/////////////////////////////////////////////////////////////////////
int[] getDivisors(int value) {
List<Integer> divisors = new ArrayList<>();
for (int divisor = 1; divisor * divisor <= value; ++divisor) {
if (value % divisor == 0) {
divisors.add(divisor);
if (divisor * divisor != value) {
divisors.add(value / divisor);
}
}
}
return castInt(divisors);
}
/////////////////////////////////////////////////////////////////////
private static long lcm(long a, long b) {
return a / gcd(a, b) * b;
}
private static long gcd(long a, long b) {
return (a == 0 ? b : gcd(b % a, a));
}
/////////////////////////////////////////////////////////////////////
private static class MultiSet<ValueType> {
public static <ValueType> MultiSet<ValueType> createMultiSet() {
Map<ValueType, Integer> multiset = new HashMap<>();
return new MultiSet<>(multiset);
}
private final Map<ValueType, Integer> multiset;
private int size;
public MultiSet(Map<ValueType, Integer> multiset) {
this.multiset = multiset;
this.size = 0;
}
public int size() {
return size;
}
public void inc(ValueType value) {
int count = get(value);
multiset.put(value, count + 1);
++size;
}
public void dec(ValueType value) {
int count = get(value);
if (count == 0) return;
if (count == 1) multiset.remove(value);
else multiset.put(value, count - 1);
--size;
}
public int get(ValueType value) {
Integer count = multiset.get(value);
return (count == null ? 0 : count);
}
}
/////////////////////////////////////////////////////////////////////
private static class IdMap<KeyType> extends HashMap<KeyType, Integer> {
/**
*
*/
private static final long serialVersionUID = -3793737771950984481L;
public IdMap() {
super();
}
int getId(KeyType key) {
Integer id = super.get(key);
if (id == null) {
super.put(key, id = size());
}
return id;
}
}
/////////////////////////////////////////////////////////////////////
private static int[] castInt(List<Integer> list) {
int[] array = new int[list.size()];
for (int i = 0; i < array.length; ++i) {
array[i] = list.get(i);
}
return array;
}
private static long[] castLong(List<Long> list) {
long[] array = new long[list.size()];
for (int i = 0; i < array.length; ++i) {
array[i] = list.get(i);
}
return array;
}
/////////////////////////////////////////////////////////////////////
/**
* Generates list with values 0..<n
* @param n - exclusive limit of sequence
*/
private static List<Integer> order(int n) {
List<Integer> sequence = new ArrayList<>();
for (int i = 0; i < n; ++i) {
sequence.add(i);
}
return sequence;
}
}
Submission Info
Submission Time |
|
Task |
C - +/- Rectangle |
User |
Slamur |
Language |
Java8 (OpenJDK 1.8.0) |
Score |
0 |
Code Size |
21945 Byte |
Status |
WA |
Exec Time |
196 ms |
Memory |
48092 KB |
Compile Error
Note: ./Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 700 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_00.txt, 0_01.txt, 0_02.txt |
All |
0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt |
Case Name |
Status |
Exec Time |
Memory |
0_00.txt |
AC |
74 ms |
20692 KB |
0_01.txt |
AC |
75 ms |
20308 KB |
0_02.txt |
AC |
72 ms |
23508 KB |
1_00.txt |
AC |
71 ms |
22100 KB |
1_01.txt |
AC |
72 ms |
21460 KB |
1_02.txt |
AC |
72 ms |
20564 KB |
1_03.txt |
WA |
70 ms |
23636 KB |
1_04.txt |
AC |
73 ms |
19792 KB |
1_05.txt |
WA |
71 ms |
20308 KB |
1_06.txt |
AC |
72 ms |
20948 KB |
1_07.txt |
AC |
95 ms |
24916 KB |
1_08.txt |
AC |
81 ms |
23508 KB |
1_09.txt |
WA |
88 ms |
23764 KB |
1_10.txt |
AC |
187 ms |
45964 KB |
1_11.txt |
WA |
83 ms |
23892 KB |
1_12.txt |
AC |
74 ms |
23508 KB |
1_13.txt |
AC |
89 ms |
25556 KB |
1_14.txt |
AC |
89 ms |
22356 KB |
1_15.txt |
AC |
181 ms |
42784 KB |
1_16.txt |
AC |
188 ms |
42080 KB |
1_17.txt |
AC |
187 ms |
41704 KB |
1_18.txt |
WA |
72 ms |
21588 KB |
1_19.txt |
WA |
85 ms |
25044 KB |
1_20.txt |
AC |
182 ms |
42916 KB |
1_21.txt |
AC |
191 ms |
43420 KB |
1_22.txt |
AC |
182 ms |
48092 KB |
1_23.txt |
AC |
180 ms |
39468 KB |
1_24.txt |
AC |
75 ms |
19284 KB |
1_25.txt |
AC |
185 ms |
45288 KB |
1_26.txt |
AC |
180 ms |
45700 KB |
1_27.txt |
AC |
191 ms |
44036 KB |
1_28.txt |
AC |
191 ms |
46948 KB |
1_29.txt |
AC |
193 ms |
42324 KB |
1_30.txt |
WA |
70 ms |
20180 KB |
1_31.txt |
WA |
84 ms |
25684 KB |
1_32.txt |
AC |
185 ms |
46496 KB |
1_33.txt |
AC |
196 ms |
47604 KB |
1_34.txt |
AC |
172 ms |
46068 KB |
1_35.txt |
WA |
88 ms |
22228 KB |
1_36.txt |
AC |
143 ms |
33620 KB |
1_37.txt |
AC |
186 ms |
43724 KB |
1_38.txt |
AC |
156 ms |
38612 KB |
1_39.txt |
AC |
129 ms |
33492 KB |
1_40.txt |
AC |
106 ms |
26068 KB |
1_41.txt |
AC |
73 ms |
23380 KB |
1_42.txt |
AC |
75 ms |
21844 KB |
1_43.txt |
AC |
121 ms |
30804 KB |
1_44.txt |
AC |
72 ms |
21588 KB |
1_45.txt |
AC |
74 ms |
23508 KB |
1_46.txt |
AC |
73 ms |
25556 KB |
1_47.txt |
AC |
145 ms |
37060 KB |
1_48.txt |
AC |
77 ms |
22484 KB |
1_49.txt |
AC |
149 ms |
43220 KB |
1_50.txt |
AC |
159 ms |
39560 KB |
1_51.txt |
AC |
119 ms |
31188 KB |
1_52.txt |
AC |
73 ms |
21972 KB |
1_53.txt |
AC |
161 ms |
38252 KB |
1_54.txt |
AC |
153 ms |
41864 KB |
1_55.txt |
AC |
123 ms |
36948 KB |
1_56.txt |
AC |
72 ms |
21588 KB |
1_57.txt |
AC |
73 ms |
21588 KB |
1_58.txt |
AC |
77 ms |
21844 KB |
1_59.txt |
AC |
86 ms |
23636 KB |