Submission #48944

# Submission time Handle Problem Language Result Execution time Memory
48944 2018-05-20T06:44:28 Z leehosu01 토마토 (KOI13_tomato) C++17
0 / 16
99 ms 1724 KB
#include<bits/stdc++.h>
using namespace std;
#define able(Y,X) if(0<=X&&X<N&&0<=Y&&Y<M&&D[Y].test(X)==0)Q.push({Y,X}),D[Y].set(X);
bitset<1000>D[1000];
int N,M,to;
struct A{int y,x;
void mov(queue<A>&Q)
{
    able(y,x-1);
    able(y,x+1);
    able(y-1,x);
    able(y+1,x);
}};
queue<A>Q;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>N>>M;
    int a;
    D[0].reset();
    for(int i=0;i<M;D[++i].reset())
        for(int j=0;j<N;j++)
        {
            cin>>a;
            if(a)D[i].set(j),Q.push({i,j}),++to;
        }
    if(to==0)printf("-1");
    else if(to==N*M)printf("0");
    else
    {
        int pl=0;
        while(to<N*M)
        {
            pl++;
            for(int i=Q.size();i;--i)
            {
                Q.front().mov(Q);
                Q.pop();
            }
            to+=Q.size();
        }
        printf("%d",pl);
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 412 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 1080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 1080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 1724 KB Output isn't correct
2 Halted 0 ms 0 KB -