# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
5639 |
2014-05-09T13:23:49 Z |
kkk123 |
토마토 (KOI13_tomato) |
C++ |
|
0 ms |
1668 KB |
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
FILE *inputs = fopen("input.txt","r");
FILE *outputs = fopen("output.txt","w");
int M = 2,N = 2;
int Riped = 0;
int notRiped = 0;
fscanf(inputs,"%d %d",&M,&N);
int tomato[N][M];
int Temp_tomato[N][M];
for (int i = 0 ; i < N; i++){
for (int j = 0 ; j < M; j++){
tomato[i][j] = 0;
Temp_tomato[i][j] = 0;
}
}
for (int i = 0 ; i < N; i++){
for (int j = 0 ; j < M; j++){
fscanf(inputs,"%d",&tomato[i][j]);
if (tomato[i][j] == 1)Riped++;
if (tomato[i][j] == -1)notRiped++;
}
}
if (Riped == M * N - notRiped){
fprintf(outputs,"%d",0);
return 0;
}
if (Riped == 0){
fprintf(outputs,"%d",-1);
return 0;
}
int Delta = 0;
int Date = -1;
while (Riped != Delta){
Delta = Riped;
Date++;
for (int i = 0; i < N; i++){
for (int j = 0 ;j < M; j++){
if (tomato[i][j] == 1){
if (i-1 >= 0 && tomato[i-1][j] == 0)Temp_tomato[i-1][j] = 1;
if (i+1 < N && tomato[i+1][j] == 0)Temp_tomato[i+1][j] = 1;
if (j-1 >= 0 && tomato[i][j-1] == 0)Temp_tomato[i][j-1] = 1;
if (j+1 < M && tomato[i][j+1] == 0)Temp_tomato[i][j+1] = 1;
}
}
}
for (int i = 0; i < N; i++){
for (int j = 0 ;j < M; j++){
if (Temp_tomato[i][j] == 1){
tomato[i][j] = 1;
Riped++;
Temp_tomato[i][j] = 0;
}
}
}
}
if (Riped == M * N - notRiped){
fprintf(outputs,"%d",Date);
return 0;
}else{
fprintf(outputs,"%d",-1);
return 0;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
1668 KB |
open (syscall #2) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |