Submission #134025

# Submission time Handle Problem Language Result Execution time Memory
134025 2019-07-22T00:19:10 Z ly20 Brunhilda’s Birthday (BOI13_brunhilda) C++17
0 / 100
1000 ms 34068 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=4123,INF=1123456789;
int dist[MAXN][MAXN];
int tb[MAXN][MAXN];
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            char c;
            scanf(" %c",&c);
            if(c=='F')
            {
                tb[i][j]=0;
            }
            if(c=='R')
            {
                tb[i][j]=1;
            }
            if(c=='.')
            {
                tb[i][j]=-1;
            }
            dist[i][j]=INF;
        }
    }
    deque<pair<int,int> > fila;
    fila.push_back(make_pair(0,0));
    dist[0][0]=1;
    while(!fila.empty())
    {
        int curx=fila.front().first,cury=fila.front().second;fila.pop_front();
        for(int i=0;i<4;i++)
        {
            int vizx=curx+dx[i],vizy=cury+dy[i];
            if(vizx<0 || vizx>=n || vizy<0 || vizy>=m)continue;
            if(tb[vizx][vizy]==-1)continue;
            if(tb[vizx][vizy]==tb[curx][cury])
            {
                if(dist[curx][cury]<dist[vizx][vizy])
                {
                    dist[vizx][vizy]=dist[curx][cury];
                    fila.push_front(make_pair(vizx,vizy));
                }
            }
            else
            {
                if(dist[curx][cury]<dist[vizx][vizy]-1)
                {
                    dist[vizx][vizy]=dist[curx][cury]+1;
                    fila.push_front(make_pair(vizx,vizy));
                }
            }
        }
    }
    int resp=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(tb[i][j]!=-1)resp=max(resp,dist[i][j]);
        }
    }
    printf("%d\n",resp);
    return 0;
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
brunhilda.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c",&c);
             ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 17 ms 632 KB Output isn't correct
3 Incorrect 2 ms 248 KB Output isn't correct
4 Incorrect 600 ms 3008 KB Output isn't correct
5 Incorrect 3 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Incorrect 3 ms 376 KB Output isn't correct
10 Incorrect 16 ms 632 KB Output isn't correct
11 Incorrect 16 ms 632 KB Output isn't correct
12 Incorrect 10 ms 760 KB Output isn't correct
13 Incorrect 849 ms 12436 KB Output isn't correct
14 Execution timed out 1077 ms 2868 KB Time limit exceeded
15 Incorrect 9 ms 504 KB Output isn't correct
16 Incorrect 17 ms 632 KB Output isn't correct
17 Incorrect 384 ms 2168 KB Output isn't correct
18 Incorrect 605 ms 2996 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 75 ms 33912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 74 ms 33916 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 73 ms 33928 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 15 ms 13048 KB Output isn't correct
5 Runtime error 74 ms 34012 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Incorrect 7 ms 5240 KB Output isn't correct
7 Runtime error 74 ms 33980 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Incorrect 6 ms 4344 KB Output isn't correct
9 Runtime error 73 ms 34040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 72 ms 34012 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 74 ms 34068 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Incorrect 11 ms 8824 KB Output isn't correct
13 Incorrect 14 ms 12152 KB Output isn't correct
14 Incorrect 15 ms 13052 KB Output isn't correct
15 Runtime error 72 ms 34040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 73 ms 34040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Incorrect 15 ms 12536 KB Output isn't correct
18 Runtime error 74 ms 34040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 1460 KB Time limit exceeded
2 Execution timed out 1086 ms 1656 KB Time limit exceeded
3 Execution timed out 1090 ms 1244 KB Time limit exceeded
4 Execution timed out 1085 ms 1144 KB Time limit exceeded
5 Execution timed out 1078 ms 1912 KB Time limit exceeded
6 Execution timed out 1078 ms 1444 KB Time limit exceeded
7 Execution timed out 1086 ms 1408 KB Time limit exceeded
8 Execution timed out 1073 ms 1652 KB Time limit exceeded
9 Execution timed out 1075 ms 1500 KB Time limit exceeded
10 Execution timed out 1078 ms 2500 KB Time limit exceeded
11 Execution timed out 1069 ms 1704 KB Time limit exceeded
12 Execution timed out 1080 ms 1532 KB Time limit exceeded
13 Execution timed out 1080 ms 1528 KB Time limit exceeded
14 Execution timed out 1078 ms 1148 KB Time limit exceeded
15 Execution timed out 1086 ms 1592 KB Time limit exceeded
16 Execution timed out 1084 ms 1656 KB Time limit exceeded
17 Execution timed out 1083 ms 2936 KB Time limit exceeded
18 Execution timed out 1071 ms 1668 KB Time limit exceeded
19 Execution timed out 1081 ms 1592 KB Time limit exceeded
20 Execution timed out 1083 ms 1400 KB Time limit exceeded
21 Execution timed out 1076 ms 1144 KB Time limit exceeded
22 Execution timed out 1082 ms 1912 KB Time limit exceeded
23 Execution timed out 1074 ms 1912 KB Time limit exceeded
24 Execution timed out 1072 ms 1272 KB Time limit exceeded
25 Execution timed out 1066 ms 1116 KB Time limit exceeded
26 Execution timed out 1081 ms 1272 KB Time limit exceeded
27 Execution timed out 1079 ms 1416 KB Time limit exceeded
28 Execution timed out 1080 ms 888 KB Time limit exceeded
29 Execution timed out 1074 ms 1928 KB Time limit exceeded
30 Execution timed out 1073 ms 1964 KB Time limit exceeded
31 Execution timed out 1078 ms 1144 KB Time limit exceeded
32 Execution timed out 1080 ms 1144 KB Time limit exceeded
33 Execution timed out 1077 ms 1244 KB Time limit exceeded
34 Execution timed out 1080 ms 1656 KB Time limit exceeded
35 Execution timed out 1082 ms 1144 KB Time limit exceeded
36 Execution timed out 1066 ms 1692 KB Time limit exceeded
37 Execution timed out 1081 ms 1800 KB Time limit exceeded
38 Execution timed out 1081 ms 1544 KB Time limit exceeded
39 Execution timed out 1090 ms 1144 KB Time limit exceeded
40 Execution timed out 1079 ms 1528 KB Time limit exceeded
41 Execution timed out 1077 ms 1400 KB Time limit exceeded
42 Execution timed out 1078 ms 1016 KB Time limit exceeded