Submission #791689

# Submission time Handle Problem Language Result Execution time Memory
791689 2023-07-24T08:51:17 Z dwuy Tracks in the Snow (BOI13_tracks) C++14
0 / 100
2000 ms 1048580 KB
/// (⌐■_■): "who's nvpu, dwuy?"
///  dwuy : "revolym"
#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) int32_t(s.length())
#define MASK(k)(1LL<<(k))
#define TASK ""
#define int long long

using namespace std;

typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;

const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;

const int MX = 4005;
const int dx[] = {0, 0, -1, 1};
const int dy[] = {-1, 1, 0, 0};

int n, m;
string a[MX];
int d[MX][MX];

void nhap(){
    cin >> n >> m;
    for(int i=0; i<n; i++) cin >> a[i];
}

void solve(){
    deque<pii> Q;
    d[1][1] = 1;
    Q.push_front({0, 0});
    int ans = 0;
    while(Q.size()){
        int x, y;
        tie(x, y) = Q.front();
        Q.pop_front();
        ans = max(ans, d[x][y]);
        for(int i=0; i<4; i++){
            int u = x + dx[i];
            int v = y + dy[i];
            if(u<0 || u>=n || v<0 || v>=m || d[u][v]!=0 || a[u][v]=='.') continue;
            if(a[u][v] == a[x][y]){
                d[u][v] = d[x][y];
                Q.push_front({u, v});
            }
            else{
                d[u][v] = d[x][y] + 1;
                Q.push_back({u, v});
            }
        }
    }
    cout << ans;
}

int32_t main(){
    fastIO;
    //file(TASK);

    nhap();
    solve();

    return 0;
}



# Verdict Execution time Memory Grader output
1 Runtime error 1869 ms 1048576 KB Execution killed with signal 9
2 Execution timed out 2005 ms 1048576 KB Time limit exceeded
3 Execution timed out 2025 ms 1048576 KB Time limit exceeded
4 Execution timed out 2113 ms 709880 KB Time limit exceeded
5 Runtime error 1949 ms 1048576 KB Execution killed with signal 9
6 Runtime error 1957 ms 1048576 KB Execution killed with signal 9
7 Runtime error 1998 ms 1048576 KB Execution killed with signal 9
8 Runtime error 1944 ms 1048576 KB Execution killed with signal 9
9 Execution timed out 2105 ms 735032 KB Time limit exceeded
10 Execution timed out 2084 ms 468 KB Time limit exceeded
11 Runtime error 1557 ms 1048576 KB Execution killed with signal 9
12 Execution timed out 2112 ms 732644 KB Time limit exceeded
13 Runtime error 1909 ms 1048576 KB Execution killed with signal 9
14 Runtime error 1946 ms 1048576 KB Execution killed with signal 9
15 Execution timed out 2114 ms 775552 KB Time limit exceeded
16 Runtime error 1551 ms 1048576 KB Execution killed with signal 9
17 Execution timed out 2124 ms 998120 KB Time limit exceeded
18 Execution timed out 2054 ms 695980 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Runtime error 1906 ms 1048576 KB Execution killed with signal 9
2 Runtime error 1897 ms 1048576 KB Execution killed with signal 9
3 Runtime error 1617 ms 1048576 KB Execution killed with signal 9
4 Runtime error 1879 ms 1048576 KB Execution killed with signal 9
5 Runtime error 1909 ms 1048576 KB Execution killed with signal 9
6 Execution timed out 2073 ms 18004 KB Time limit exceeded
7 Runtime error 1970 ms 1048576 KB Execution killed with signal 9
8 Runtime error 1958 ms 1048576 KB Execution killed with signal 9
9 Runtime error 1562 ms 1048576 KB Execution killed with signal 9
10 Execution timed out 2086 ms 720908 KB Time limit exceeded
11 Runtime error 1947 ms 1048576 KB Execution killed with signal 9
12 Execution timed out 2087 ms 727476 KB Time limit exceeded
13 Runtime error 1900 ms 1048576 KB Execution killed with signal 9
14 Runtime error 1938 ms 1048576 KB Execution killed with signal 9
15 Runtime error 1958 ms 1048580 KB Execution killed with signal 9
16 Execution timed out 2123 ms 748964 KB Time limit exceeded
17 Runtime error 1977 ms 1048576 KB Execution killed with signal 9
18 Runtime error 1927 ms 1048576 KB Execution killed with signal 9
19 Runtime error 1879 ms 1048576 KB Execution killed with signal 9
20 Runtime error 1368 ms 1048576 KB Execution killed with signal 9
21 Runtime error 1891 ms 1048576 KB Execution killed with signal 9
22 Runtime error 1952 ms 1048576 KB Execution killed with signal 9
23 Execution timed out 2090 ms 8788 KB Time limit exceeded
24 Execution timed out 2084 ms 688772 KB Time limit exceeded
25 Execution timed out 2077 ms 730496 KB Time limit exceeded
26 Runtime error 1529 ms 1048576 KB Execution killed with signal 9
27 Runtime error 1550 ms 1048576 KB Execution killed with signal 9
28 Execution timed out 2056 ms 18004 KB Time limit exceeded
29 Execution timed out 2112 ms 717944 KB Time limit exceeded
30 Runtime error 1568 ms 1048576 KB Execution killed with signal 9
31 Runtime error 1889 ms 1048576 KB Execution killed with signal 9
32 Runtime error 1626 ms 1048576 KB Execution killed with signal 9