Submission #883153

# Submission time Handle Problem Language Result Execution time Memory
883153 2023-12-04T16:24:28 Z Servant_of_the_Lord Mecho (IOI09_mecho) C++17
5 / 100
442 ms 65540 KB
#include <bits/stdc++.h>
#define ll long long

using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll x,y,z,a,b,c,d,e;
    cin>>x>>y;
    vector<string>v;
    vector<vector<ll>>w,u;
    for(ll i=0;i<x;i++)
    {
        string s;
        cin>>s;
        v.push_back(s);
        for(ll j=0;j<x;j++)
        {
            if(v[i][j]=='M')w.push_back({i,j});
            if(v[i][j]=='H')u.push_back({i,j});
            if(v[i][j]=='D')d=i,e=j;
            
        }
    }
    
    a=0,b=5;
    while(a<b)
    {
        ll m=a+(b-a+1)/2;
        bool o=false;
        vector<vector<ll>>q,r;
        vector<vector<bool>>t(x,vector<bool>(x)),s(x,vector<bool>(x));
        
        function<void()>bees=[&]()
        {
            vector<vector<ll>>q2;
            function<void(ll,ll)>ba=[&](ll a,ll b)
            {
                if(a>=0&&a<x&&b>=0&&b<x&&t[a][b]==false)
                {
                    q2.push_back({a,b});
                    t[a][b]=true;
                }
                
            };
            for(ll i=0;i<q.size();i++)
            {
                ba(q[i][0]-1,q[i][1]);
                ba(q[i][0]+1,q[i][1]);
                ba(q[i][0],q[i][1]-1);
                ba(q[i][0],q[i][1]+1);
            }
            q2.swap(q);
        };
        function<void()>bear=[&]()
        {
            vector<vector<ll>>r2;
            function<void(ll,ll)>ba=[&](ll a,ll b)
            {
                if(a>=0&&a<x&&b>=0&&b<x&&t[a][b]==false&&s[a][b]==false&&(v[a][b]=='G'||v[a][b]=='D'))
                {
                    r2.push_back({a,b});
                    if(a==d&&b==e)o=true;
                }
                
            };
            for(ll i=0;i<r.size();i++)
            {
                ba(r[i][0]-1,r[i][1]);
                ba(r[i][0]+1,r[i][1]);
                ba(r[i][0],r[i][1]-1);
                ba(r[i][0],r[i][1]+1);
            }
            r2.swap(r);
        };
        for(auto i:w)r.push_back(i);
        for(auto i:u)q.push_back(i);
        for(ll i=0;i<m;i++)
        {
            bees();
        }
        while(r.size())
        {
            
            for(ll i=0;i<y;i++)bear();
            bees();
            vector<vector<ll>>r2;
            for(ll i=0;i<r.size();i++)
            {
                if(!t[r[i][0]][r[i][1]])
                {
                    r2.push_back(r[i]);
                    s[r[i][0]][r[i][1]]=true;
                }
            }
            r2.swap(r);
        }
        if(o)a=m;
        else b=m-1;
    }
    cout<<a<<'\n';
}

Compilation message

mecho.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~
mecho.cpp: In lambda function:
mecho.cpp:49:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             for(ll i=0;i<q.size();i++)
      |                        ~^~~~~~~~~
mecho.cpp: In lambda function:
mecho.cpp:70:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             for(ll i=0;i<r.size();i++)
      |                        ~^~~~~~~~~
mecho.cpp: In function 'int main()':
mecho.cpp:91:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |             for(ll i=0;i<r.size();i++)
      |                        ~^~~~~~~~~
mecho.cpp:11:12: warning: unused variable 'z' [-Wunused-variable]
   11 |     ll x,y,z,a,b,c,d,e;
      |            ^
mecho.cpp:11:18: warning: unused variable 'c' [-Wunused-variable]
   11 |     ll x,y,z,a,b,c,d,e;
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Runtime error 62 ms 65536 KB Execution killed with signal 9
8 Incorrect 1 ms 344 KB Output isn't correct
9 Runtime error 91 ms 65536 KB Execution killed with signal 9
10 Correct 1 ms 344 KB Output is correct
11 Incorrect 2 ms 736 KB Output isn't correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Runtime error 152 ms 65536 KB Execution killed with signal 9
14 Runtime error 88 ms 65536 KB Execution killed with signal 9
15 Incorrect 1 ms 344 KB Output isn't correct
16 Incorrect 4 ms 688 KB Output isn't correct
17 Incorrect 0 ms 348 KB Output isn't correct
18 Incorrect 31 ms 2712 KB Output isn't correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Incorrect 199 ms 19540 KB Output isn't correct
21 Incorrect 1 ms 348 KB Output isn't correct
22 Runtime error 87 ms 65536 KB Execution killed with signal 9
23 Incorrect 1 ms 348 KB Output isn't correct
24 Runtime error 83 ms 65536 KB Execution killed with signal 9
25 Incorrect 1 ms 600 KB Output isn't correct
26 Runtime error 83 ms 65536 KB Execution killed with signal 9
27 Incorrect 1 ms 348 KB Output isn't correct
28 Runtime error 78 ms 65536 KB Execution killed with signal 9
29 Incorrect 1 ms 348 KB Output isn't correct
30 Runtime error 86 ms 65536 KB Execution killed with signal 9
31 Incorrect 1 ms 348 KB Output isn't correct
32 Runtime error 91 ms 65536 KB Execution killed with signal 9
33 Incorrect 13 ms 856 KB Output isn't correct
34 Runtime error 112 ms 65536 KB Execution killed with signal 9
35 Runtime error 75 ms 65536 KB Execution killed with signal 9
36 Incorrect 28 ms 856 KB Output isn't correct
37 Runtime error 82 ms 65536 KB Execution killed with signal 9
38 Runtime error 76 ms 65536 KB Execution killed with signal 9
39 Incorrect 21 ms 860 KB Output isn't correct
40 Runtime error 102 ms 65540 KB Execution killed with signal 9
41 Runtime error 77 ms 65536 KB Execution killed with signal 9
42 Incorrect 43 ms 1116 KB Output isn't correct
43 Runtime error 95 ms 65536 KB Execution killed with signal 9
44 Runtime error 76 ms 65536 KB Execution killed with signal 9
45 Incorrect 32 ms 1116 KB Output isn't correct
46 Runtime error 95 ms 65536 KB Execution killed with signal 9
47 Runtime error 78 ms 65536 KB Execution killed with signal 9
48 Incorrect 61 ms 1368 KB Output isn't correct
49 Runtime error 84 ms 65536 KB Execution killed with signal 9
50 Runtime error 71 ms 65536 KB Execution killed with signal 9
51 Incorrect 45 ms 1628 KB Output isn't correct
52 Runtime error 97 ms 65536 KB Execution killed with signal 9
53 Runtime error 70 ms 65536 KB Execution killed with signal 9
54 Incorrect 95 ms 1788 KB Output isn't correct
55 Runtime error 83 ms 65536 KB Execution killed with signal 9
56 Runtime error 71 ms 65536 KB Execution killed with signal 9
57 Incorrect 59 ms 2084 KB Output isn't correct
58 Runtime error 76 ms 65536 KB Execution killed with signal 9
59 Runtime error 71 ms 65536 KB Execution killed with signal 9
60 Incorrect 107 ms 2132 KB Output isn't correct
61 Runtime error 83 ms 65536 KB Execution killed with signal 9
62 Runtime error 81 ms 65536 KB Execution killed with signal 9
63 Correct 22 ms 2148 KB Output is correct
64 Runtime error 76 ms 65536 KB Execution killed with signal 9
65 Incorrect 192 ms 2344 KB Output isn't correct
66 Incorrect 9 ms 2136 KB Output isn't correct
67 Incorrect 95 ms 2164 KB Output isn't correct
68 Runtime error 79 ms 65536 KB Execution killed with signal 9
69 Runtime error 77 ms 65536 KB Execution killed with signal 9
70 Runtime error 150 ms 65536 KB Execution killed with signal 9
71 Incorrect 442 ms 23608 KB Output isn't correct
72 Runtime error 77 ms 65536 KB Execution killed with signal 9
73 Runtime error 88 ms 65536 KB Execution killed with signal 9
74 Runtime error 57 ms 65536 KB Execution killed with signal 9
75 Runtime error 73 ms 65536 KB Execution killed with signal 9
76 Runtime error 120 ms 65536 KB Execution killed with signal 9
77 Runtime error 57 ms 65536 KB Execution killed with signal 9
78 Runtime error 57 ms 65536 KB Execution killed with signal 9
79 Runtime error 58 ms 65536 KB Execution killed with signal 9
80 Runtime error 57 ms 65536 KB Execution killed with signal 9
81 Runtime error 68 ms 65536 KB Execution killed with signal 9
82 Runtime error 57 ms 65536 KB Execution killed with signal 9
83 Runtime error 76 ms 65536 KB Execution killed with signal 9
84 Runtime error 57 ms 65536 KB Execution killed with signal 9
85 Runtime error 57 ms 65536 KB Execution killed with signal 9
86 Runtime error 56 ms 65536 KB Execution killed with signal 9
87 Runtime error 56 ms 65536 KB Execution killed with signal 9
88 Runtime error 64 ms 65536 KB Execution killed with signal 9
89 Runtime error 55 ms 65536 KB Execution killed with signal 9
90 Runtime error 55 ms 65536 KB Execution killed with signal 9
91 Runtime error 64 ms 65536 KB Execution killed with signal 9
92 Runtime error 56 ms 65536 KB Execution killed with signal 9