Submission #104307

# Submission time Handle Problem Language Result Execution time Memory
104307 2019-04-05T03:40:35 Z Badral Mecho (IOI09_mecho) C++17
4 / 100
126 ms 8440 KB
#include<bits/stdc++.h>

using namespace std;

#define pi pair<int, int>
 
char a[1015][1015];
int dx[] = {0, 0, 0, 1, -1, -1, 1, 1, -1};
int dy[] = {0, 1, -1, 0, 0, -1, -1, 1, 1};
int bear[1105][1015], bee[1105][1015], xx = -1, yy = -1, xxx = -1, yyy = -1, n, kk;
 
bool asdasd = 0;
 
bool can(int k) {
 
    if ( k >= bee[xx][yy] ) return 0;
 
    for ( int i = 1; i <= n; i++ ) 
        for ( int j = 1; j <= n; j++ ) 
            bear[i][j] = INT_MAX;
 
    bear[xx][yy] = 0;
 
    queue < pi > q;
    
    q.push(make_pair(xx, yy));
        int x, y;    
    while(!q.empty()) {
        tie(x, y) = q.front();
        q.pop();
        for(int i = 1; i <= 4; i++) {
            int x1 = x + dx[i], y1 = y + dy[i];
            if ( a[x1][y1] == 'D' ) {asdasd = 1; return 1;}
            if ( a[x1][y1] == 'G' && bear[x][y] + 1 < kk * ( bee[x1][y1] - k ) && bear[x1][y1] == INT_MAX ) {
                bear[x1][y1] = bear[x][y] + 1;
                q.push ( make_pair ( x1, y1 ) ); 
            }
        }
    }
    return 0;  
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> kk;
    queue < pi > p;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            bee[i][j] = INT_MAX; 
            a[i][j] = getchar();
            if ( a[i][j] == 'H' ) {p.push(make_pair(i, j)); bee[i][j] = 0;}
            if ( a[i][j] == 'M' ) xx = i, yy = j;
        }
    }
 
    while(!p.empty()) {
        int x, y; tie(x, y) = p.front(); p.pop();
        for ( int i = 1; i <= 4; i++ ) {
            int x1 = x + dx[i], y1 = y + dy[i];
            if ( bee[x1][y1] == INT_MAX && ( a[x1][y1] == 'G' || a[x1][y1] == 'M' ) ) {
                bee[x1][y1] = bee[x][y] + 1; p.push ( make_pair ( x1, y1 ) );
            }
        }
    }
 
    int k = 0, mm = n * n / 2 ;
    
	for(int i = mm/2; i >= 1; i /= 2) 
        while(i + k <= mm && can(i+k)) 
            k += i;
	
    bool pppp = can(0);
    if ( !asdasd ) cout << -1;
    else cout << k;
}

Compilation message

mecho.cpp: In function 'int main()':
mecho.cpp:74:10: warning: unused variable 'pppp' [-Wunused-variable]
     bool pppp = can(0);
          ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Output isn't correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Incorrect 3 ms 384 KB Output isn't correct
5 Incorrect 4 ms 512 KB Output isn't correct
6 Incorrect 3 ms 384 KB Output isn't correct
7 Incorrect 41 ms 8188 KB Output isn't correct
8 Correct 2 ms 512 KB Output is correct
9 Incorrect 3 ms 512 KB Output isn't correct
10 Incorrect 2 ms 512 KB Output isn't correct
11 Incorrect 3 ms 572 KB Output isn't correct
12 Incorrect 4 ms 896 KB Output isn't correct
13 Incorrect 4 ms 640 KB Output isn't correct
14 Correct 5 ms 896 KB Output is correct
15 Incorrect 3 ms 640 KB Output isn't correct
16 Incorrect 3 ms 512 KB Output isn't correct
17 Incorrect 4 ms 512 KB Output isn't correct
18 Incorrect 3 ms 640 KB Output isn't correct
19 Incorrect 4 ms 640 KB Output isn't correct
20 Incorrect 4 ms 640 KB Output isn't correct
21 Incorrect 3 ms 768 KB Output isn't correct
22 Incorrect 4 ms 768 KB Output isn't correct
23 Incorrect 4 ms 896 KB Output isn't correct
24 Incorrect 4 ms 896 KB Output isn't correct
25 Incorrect 4 ms 896 KB Output isn't correct
26 Incorrect 6 ms 896 KB Output isn't correct
27 Incorrect 5 ms 1024 KB Output isn't correct
28 Incorrect 5 ms 1024 KB Output isn't correct
29 Incorrect 5 ms 996 KB Output isn't correct
30 Incorrect 5 ms 1024 KB Output isn't correct
31 Incorrect 5 ms 1024 KB Output isn't correct
32 Incorrect 6 ms 1024 KB Output isn't correct
33 Incorrect 12 ms 3584 KB Output isn't correct
34 Incorrect 12 ms 3584 KB Output isn't correct
35 Incorrect 15 ms 3584 KB Output isn't correct
36 Incorrect 13 ms 4096 KB Output isn't correct
37 Incorrect 12 ms 4096 KB Output isn't correct
38 Incorrect 12 ms 4096 KB Output isn't correct
39 Incorrect 13 ms 4608 KB Output isn't correct
40 Incorrect 12 ms 4608 KB Output isn't correct
41 Incorrect 14 ms 4608 KB Output isn't correct
42 Incorrect 15 ms 5120 KB Output isn't correct
43 Incorrect 16 ms 5112 KB Output isn't correct
44 Incorrect 16 ms 5112 KB Output isn't correct
45 Incorrect 20 ms 5632 KB Output isn't correct
46 Incorrect 20 ms 5496 KB Output isn't correct
47 Incorrect 16 ms 5632 KB Output isn't correct
48 Incorrect 15 ms 6144 KB Output isn't correct
49 Incorrect 18 ms 6144 KB Output isn't correct
50 Incorrect 16 ms 6144 KB Output isn't correct
51 Incorrect 19 ms 6528 KB Output isn't correct
52 Incorrect 17 ms 6528 KB Output isn't correct
53 Incorrect 23 ms 6620 KB Output isn't correct
54 Incorrect 24 ms 7040 KB Output isn't correct
55 Incorrect 21 ms 7012 KB Output isn't correct
56 Incorrect 20 ms 7040 KB Output isn't correct
57 Incorrect 25 ms 7680 KB Output isn't correct
58 Incorrect 26 ms 7544 KB Output isn't correct
59 Incorrect 25 ms 7672 KB Output isn't correct
60 Incorrect 28 ms 8184 KB Output isn't correct
61 Incorrect 24 ms 8192 KB Output isn't correct
62 Incorrect 28 ms 8192 KB Output isn't correct
63 Incorrect 35 ms 8056 KB Output isn't correct
64 Incorrect 41 ms 8184 KB Output isn't correct
65 Incorrect 37 ms 8056 KB Output isn't correct
66 Incorrect 52 ms 8184 KB Output isn't correct
67 Correct 36 ms 8056 KB Output is correct
68 Incorrect 56 ms 8184 KB Output isn't correct
69 Incorrect 63 ms 8184 KB Output isn't correct
70 Incorrect 50 ms 8184 KB Output isn't correct
71 Incorrect 49 ms 8312 KB Output isn't correct
72 Incorrect 63 ms 8184 KB Output isn't correct
73 Incorrect 41 ms 8372 KB Output isn't correct
74 Incorrect 45 ms 8440 KB Output isn't correct
75 Incorrect 45 ms 8312 KB Output isn't correct
76 Incorrect 50 ms 8440 KB Output isn't correct
77 Incorrect 58 ms 8440 KB Output isn't correct
78 Correct 78 ms 8320 KB Output is correct
79 Incorrect 126 ms 8440 KB Output isn't correct
80 Incorrect 66 ms 8328 KB Output isn't correct
81 Incorrect 72 ms 8440 KB Output isn't correct
82 Incorrect 91 ms 8340 KB Output isn't correct
83 Incorrect 39 ms 8312 KB Output isn't correct
84 Incorrect 48 ms 8312 KB Output isn't correct
85 Incorrect 45 ms 8312 KB Output isn't correct
86 Incorrect 42 ms 8308 KB Output isn't correct
87 Incorrect 45 ms 8312 KB Output isn't correct
88 Incorrect 40 ms 8312 KB Output isn't correct
89 Incorrect 42 ms 8312 KB Output isn't correct
90 Incorrect 46 ms 8312 KB Output isn't correct
91 Incorrect 43 ms 8312 KB Output isn't correct
92 Incorrect 40 ms 8312 KB Output isn't correct