#include <stdio.h>
#include <stdlib.h>
int main(){
int i,j,k;
int a,b;
int **mat;
mat
= (int**)malloc(a
* sizeof(int*)); if (mat == NULL) {
fprintf(stderr
, "Memory allocation failed for row pointers.\n"); return 1;
}
for(i = 0; i < a; i++){
mat
[i
] = (int*)malloc(b
* sizeof(int)); if (mat[i] == NULL) {
fprintf(stderr
, "Memory allocation failed for row %d.\n", i
); for (int l = 0; l < i; l++) {
}
return 1;
}
}
int counter = 1;
for(i = 0; i < a; i++){
for(j = 0; j < b; j++){
mat[i][j] = counter;
counter++;
}
}
for(i=0;i<a;i++){
for(j=0;j<b;j++){
}
}
for(i = 0; i < a; i++){
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCgppbnQgbWFpbigpewogICAgaW50IGksaixrOwogICAgaW50IGEsYjsgCiAgICBpbnQgKiptYXQ7CiAgICBzY2FuZigiJWQgJWQiLCZhLCZiKTsKCiAgICBtYXQgPSAoaW50KiopbWFsbG9jKGEgKiBzaXplb2YoaW50KikpOwogICAgaWYgKG1hdCA9PSBOVUxMKSB7CiAgICAgICAgZnByaW50ZihzdGRlcnIsICJNZW1vcnkgYWxsb2NhdGlvbiBmYWlsZWQgZm9yIHJvdyBwb2ludGVycy5cbiIpOwogICAgICAgIHJldHVybiAxOwogICAgfQogICAgCiAgICBmb3IoaSA9IDA7IGkgPCBhOyBpKyspewogICAgICAgIG1hdFtpXSA9IChpbnQqKW1hbGxvYyhiICogc2l6ZW9mKGludCkpOwogICAgICAgIGlmIChtYXRbaV0gPT0gTlVMTCkgewogICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgIk1lbW9yeSBhbGxvY2F0aW9uIGZhaWxlZCBmb3Igcm93ICVkLlxuIiwgaSk7CiAgICAgICAgICAgIGZvciAoaW50IGwgPSAwOyBsIDwgaTsgbCsrKSB7CiAgICAgICAgICAgICAgICBmcmVlKG1hdFtsXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZnJlZShtYXQpOwogICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICB9CiAgICB9CiAgICAKICAgIAoKICAgIGludCBjb3VudGVyID0gMTsgCiAgICBmb3IoaSA9IDA7IGkgPCBhOyBpKyspewogICAgICAgIGZvcihqID0gMDsgaiA8IGI7IGorKyl7CiAgICAgICAgICAgIG1hdFtpXVtqXSA9IGNvdW50ZXI7CiAgICAgICAgICAgIGNvdW50ZXIrKzsKICAgICAgICB9CiAgICB9CiAgICAKCiAgICBmb3IoaT0wO2k8YTtpKyspewogICAgICAgIGZvcihqPTA7ajxiO2orKyl7CiAgICAgICAgICAgIHByaW50ZigiJWQgIixtYXRbaV1bal0pOwogICAgICAgIH0KICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CiAgICAKCiAgICBmb3IoaSA9IDA7IGkgPCBhOyBpKyspewogICAgICAgIGZyZWUobWF0W2ldKTsKICAgIH0KICAgIGZyZWUobWF0KTsKCgogICAgcmV0dXJuIDA7Cn0=