답안 #134026

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134026 2019-07-22T00:20:47 Z ly20 Brunhilda’s Birthday (BOI13_brunhilda) C++17
0 / 100
1000 ms 34044 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_back(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);
             ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 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 376 KB Output isn't correct
4 Incorrect 601 ms 3060 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 2 ms 376 KB Output isn't correct
10 Incorrect 16 ms 604 KB Output isn't correct
11 Incorrect 15 ms 504 KB Output isn't correct
12 Incorrect 10 ms 760 KB Output isn't correct
13 Incorrect 849 ms 12588 KB Output isn't correct
14 Execution timed out 1081 ms 2808 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 383 ms 2168 KB Output isn't correct
18 Incorrect 606 ms 2936 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 74 ms 33912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 73 ms 34040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 73 ms 34040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 16 ms 13020 KB Output isn't correct
5 Runtime error 73 ms 33912 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 34040 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 74 ms 33912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 75 ms 33912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 73 ms 34044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Incorrect 11 ms 8952 KB Output isn't correct
13 Incorrect 15 ms 12152 KB Output isn't correct
14 Incorrect 15 ms 12920 KB Output isn't correct
15 Runtime error 73 ms 34040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 73 ms 33912 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 33916 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 1228 KB Time limit exceeded
2 Execution timed out 1080 ms 1564 KB Time limit exceeded
3 Execution timed out 1070 ms 1096 KB Time limit exceeded
4 Execution timed out 1082 ms 1016 KB Time limit exceeded
5 Execution timed out 1087 ms 1144 KB Time limit exceeded
6 Execution timed out 1077 ms 1196 KB Time limit exceeded
7 Execution timed out 1076 ms 1400 KB Time limit exceeded
8 Execution timed out 1077 ms 1480 KB Time limit exceeded
9 Execution timed out 1078 ms 1452 KB Time limit exceeded
10 Execution timed out 1076 ms 2440 KB Time limit exceeded
11 Execution timed out 1061 ms 1560 KB Time limit exceeded
12 Execution timed out 1070 ms 1564 KB Time limit exceeded
13 Execution timed out 1087 ms 1144 KB Time limit exceeded
14 Execution timed out 1083 ms 1272 KB Time limit exceeded
15 Execution timed out 1082 ms 1596 KB Time limit exceeded
16 Execution timed out 1079 ms 1668 KB Time limit exceeded
17 Execution timed out 1081 ms 2728 KB Time limit exceeded
18 Execution timed out 1073 ms 1704 KB Time limit exceeded
19 Execution timed out 1070 ms 1692 KB Time limit exceeded
20 Execution timed out 1080 ms 1176 KB Time limit exceeded
21 Execution timed out 1075 ms 1208 KB Time limit exceeded
22 Execution timed out 1082 ms 1232 KB Time limit exceeded
23 Execution timed out 1064 ms 1200 KB Time limit exceeded
24 Execution timed out 1073 ms 1012 KB Time limit exceeded
25 Execution timed out 1084 ms 988 KB Time limit exceeded
26 Execution timed out 1073 ms 1128 KB Time limit exceeded
27 Execution timed out 1081 ms 1304 KB Time limit exceeded
28 Execution timed out 1048 ms 1140 KB Time limit exceeded
29 Execution timed out 1082 ms 1236 KB Time limit exceeded
30 Execution timed out 1078 ms 1092 KB Time limit exceeded
31 Execution timed out 1078 ms 984 KB Time limit exceeded
32 Execution timed out 1063 ms 1028 KB Time limit exceeded
33 Execution timed out 1073 ms 1028 KB Time limit exceeded
34 Execution timed out 1025 ms 1212 KB Time limit exceeded
35 Execution timed out 1062 ms 996 KB Time limit exceeded
36 Execution timed out 1060 ms 1124 KB Time limit exceeded
37 Execution timed out 1060 ms 1108 KB Time limit exceeded
38 Execution timed out 1079 ms 1116 KB Time limit exceeded
39 Execution timed out 1085 ms 1204 KB Time limit exceeded
40 Execution timed out 1074 ms 1144 KB Time limit exceeded
41 Execution timed out 1086 ms 1224 KB Time limit exceeded
42 Execution timed out 1073 ms 1064 KB Time limit exceeded