답안 #1031696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031696 2024-07-23T04:32:13 Z ezzzay Mecho (IOI09_mecho) C++14
2 / 100
1000 ms 4572 KB
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define int long long
const int N=1000;
char arr[N][N];
bool vis[N][N];
int xx[4]={1,-1,0,0};
int yy[4]={0,0,-1,1};
int sx,sy,fx,fy;
char brr[N][N],crr[N][N];
int n,s;
void dfs(int y, int x){
    vis[y][x]=1;
    for(int i=0;i<4;i++){
        if((brr[y+yy[i]][x+xx[i]]=='G' or brr[y+yy[i]][x+xx[i]]=='D') and vis[y+yy[i]][x+xx[i]]==0 ){
            dfs(y+yy[i],x+xx[i]);
        }
    }
}
bool check(int t){
    int h=t;
    while(h--){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                crr[i][j]=brr[i][j];
                vis[i][j]=0;
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                for(int k=0;k<4;k++){
                    if(crr[i+yy[k]][j+xx[k]]=='G' and crr[i][j]=='H'){
                        brr[i+yy[k]][j+xx[k]]='H';
                    }
                }
            }
        }
    }
    vis[sy][sx]=1;
    dfs(sy,sx);
    return vis[fy][fx];
}
signed main(){
   
    cin>>n>>s;
   
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>arr[i][j];
            if(arr[i][j]=='M'){
                sy=i;
                sx=j;
            }
            if(arr[i][j]=='D'){
                fy=i;
                fx=j;
            }
        }
    }
    
    int lo=0,hi=10000;
     
    while(hi>=lo){
        int mid=(hi+lo)/2;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                brr[i][j]=arr[i][j];
            }
        }
        if(check(mid)){
            lo=mid+1;
        }
        else{
            hi=mid-1;
        }
    }
    cout<<hi-2;
}

Compilation message

mecho.cpp: In function 'bool check(long long int)':
mecho.cpp:36:46: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   36 |                         brr[i+yy[k]][j+xx[k]]='H';
      |                         ~~~~~~~~~~~~~~~~~~~~~^~~~
mecho.cpp:13:6: note: at offset 0 to object 'brr' with size 1000000 declared here
   13 | char brr[N][N],crr[N][N];
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Incorrect 2 ms 2396 KB Output isn't correct
3 Incorrect 2 ms 2396 KB Output isn't correct
4 Correct 2 ms 2396 KB Output is correct
5 Incorrect 3 ms 2396 KB Output isn't correct
6 Incorrect 4 ms 2396 KB Output isn't correct
7 Execution timed out 1036 ms 4444 KB Time limit exceeded
8 Incorrect 9 ms 2392 KB Output isn't correct
9 Incorrect 9 ms 2524 KB Output isn't correct
10 Incorrect 10 ms 2396 KB Output isn't correct
11 Correct 12 ms 2396 KB Output is correct
12 Execution timed out 1098 ms 2396 KB Time limit exceeded
13 Incorrect 82 ms 2584 KB Output isn't correct
14 Incorrect 117 ms 2644 KB Output isn't correct
15 Incorrect 17 ms 2396 KB Output isn't correct
16 Incorrect 17 ms 2536 KB Output isn't correct
17 Incorrect 29 ms 2396 KB Output isn't correct
18 Incorrect 26 ms 2544 KB Output isn't correct
19 Incorrect 47 ms 2532 KB Output isn't correct
20 Incorrect 40 ms 2396 KB Output isn't correct
21 Incorrect 99 ms 2392 KB Output isn't correct
22 Incorrect 73 ms 2392 KB Output isn't correct
23 Incorrect 192 ms 2396 KB Output isn't correct
24 Incorrect 144 ms 2588 KB Output isn't correct
25 Incorrect 395 ms 2396 KB Output isn't correct
26 Incorrect 236 ms 2392 KB Output isn't correct
27 Incorrect 488 ms 2644 KB Output isn't correct
28 Incorrect 318 ms 2620 KB Output isn't correct
29 Incorrect 605 ms 2624 KB Output isn't correct
30 Incorrect 392 ms 2644 KB Output isn't correct
31 Incorrect 847 ms 2636 KB Output isn't correct
32 Incorrect 501 ms 2396 KB Output isn't correct
33 Execution timed out 1052 ms 3164 KB Time limit exceeded
34 Execution timed out 1029 ms 3160 KB Time limit exceeded
35 Execution timed out 1066 ms 3164 KB Time limit exceeded
36 Execution timed out 1043 ms 3160 KB Time limit exceeded
37 Execution timed out 1075 ms 3164 KB Time limit exceeded
38 Execution timed out 1049 ms 3164 KB Time limit exceeded
39 Execution timed out 1060 ms 3408 KB Time limit exceeded
40 Execution timed out 1016 ms 3416 KB Time limit exceeded
41 Execution timed out 1066 ms 3420 KB Time limit exceeded
42 Execution timed out 1039 ms 3416 KB Time limit exceeded
43 Execution timed out 1070 ms 3420 KB Time limit exceeded
44 Execution timed out 1064 ms 3420 KB Time limit exceeded
45 Execution timed out 1060 ms 3676 KB Time limit exceeded
46 Execution timed out 1057 ms 3676 KB Time limit exceeded
47 Execution timed out 1067 ms 3676 KB Time limit exceeded
48 Execution timed out 1016 ms 3672 KB Time limit exceeded
49 Execution timed out 1075 ms 3676 KB Time limit exceeded
50 Execution timed out 1064 ms 3676 KB Time limit exceeded
51 Execution timed out 1004 ms 3932 KB Time limit exceeded
52 Execution timed out 1050 ms 3916 KB Time limit exceeded
53 Execution timed out 1026 ms 3928 KB Time limit exceeded
54 Execution timed out 1079 ms 4188 KB Time limit exceeded
55 Execution timed out 1038 ms 4184 KB Time limit exceeded
56 Execution timed out 1096 ms 4176 KB Time limit exceeded
57 Execution timed out 1035 ms 4184 KB Time limit exceeded
58 Execution timed out 1060 ms 4188 KB Time limit exceeded
59 Execution timed out 1071 ms 4176 KB Time limit exceeded
60 Execution timed out 1092 ms 4432 KB Time limit exceeded
61 Execution timed out 1040 ms 4432 KB Time limit exceeded
62 Execution timed out 1059 ms 4436 KB Time limit exceeded
63 Execution timed out 1030 ms 4440 KB Time limit exceeded
64 Execution timed out 1074 ms 4392 KB Time limit exceeded
65 Execution timed out 1038 ms 4432 KB Time limit exceeded
66 Execution timed out 1049 ms 4436 KB Time limit exceeded
67 Execution timed out 1087 ms 4440 KB Time limit exceeded
68 Execution timed out 1091 ms 4432 KB Time limit exceeded
69 Execution timed out 1055 ms 4444 KB Time limit exceeded
70 Execution timed out 1049 ms 4432 KB Time limit exceeded
71 Execution timed out 1089 ms 4516 KB Time limit exceeded
72 Execution timed out 1070 ms 4188 KB Time limit exceeded
73 Execution timed out 1091 ms 4188 KB Time limit exceeded
74 Execution timed out 1080 ms 4100 KB Time limit exceeded
75 Execution timed out 1081 ms 4556 KB Time limit exceeded
76 Execution timed out 1052 ms 4444 KB Time limit exceeded
77 Execution timed out 1074 ms 4436 KB Time limit exceeded
78 Execution timed out 1069 ms 4444 KB Time limit exceeded
79 Execution timed out 1075 ms 4444 KB Time limit exceeded
80 Execution timed out 1065 ms 4504 KB Time limit exceeded
81 Execution timed out 1059 ms 4368 KB Time limit exceeded
82 Execution timed out 1026 ms 4440 KB Time limit exceeded
83 Execution timed out 1074 ms 4436 KB Time limit exceeded
84 Execution timed out 1031 ms 4440 KB Time limit exceeded
85 Execution timed out 1036 ms 4432 KB Time limit exceeded
86 Execution timed out 1053 ms 4444 KB Time limit exceeded
87 Execution timed out 1064 ms 4380 KB Time limit exceeded
88 Execution timed out 1031 ms 4432 KB Time limit exceeded
89 Execution timed out 1054 ms 4572 KB Time limit exceeded
90 Execution timed out 1046 ms 4444 KB Time limit exceeded
91 Execution timed out 1064 ms 4444 KB Time limit exceeded
92 Execution timed out 1067 ms 4432 KB Time limit exceeded