답안 #484889

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484889 2021-11-05T17:30:41 Z ali22413836 Tracks in the Snow (BOI13_tracks) C++14
51.875 / 100
70 ms 36808 KB
#include <bits/stdc++.h>
#define  endl "\n"
using namespace std ;
typedef long long ll;
typedef long double ld ;
const int N=2e7;
const ll inf=1e18 ;
const ll mod = 1e9 + 7 ;
ll mypower(ll x, ll y){
    if(y == 0) return 1 ;
    if(y == 1) return x ;
    ll ret = mypower(x , y / 2);
    ret = (ret * ret) % mod;
    if(y % 2) ret = ( ret * x ) % mod ;
    return ret ;
}
ll n , m ;
char a[2000][2000] ;
ll vis[2000][2000] ;
ll sta , sta2 , en , en2 ;
ll di[] = {0 , 0 , 1 , -1} , di2[] = {1 , -1 , 0 , 0} ;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m ;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i] ;
    }
    deque < pair < ll , ll > > q ;
    q.push_back({sta , sta2}) ;
    sta = 0 , sta2 =  0 ;
    vis[sta][sta2] = 1 ;
    ll ans = 0  ;
    while(!q.empty()){
        pair < ll , ll > x  ;
        x = q.front() ;
        q.pop_front() ;
        ans = max(ans , vis[x.first][x.second])  ;
        ll i = x.first , j = x.second ;
        for(int k = 0 ; k < 4 ; k++){
            ll ni = i + di[k] , nj = j + di2[k] ;
            if(ni < n && ni >= 0 && nj < m && nj >= 0 && a[ni][nj] != '.' && vis[ni][nj] == 0){
                if(a[ni][nj] == a[i][j]){
                    q.push_front({ni , nj}) ;
                    vis[ni][nj] = vis[i][j]  ;
                }
                else{
                    q.push_back({ni , nj}) ;
                    vis[ni][nj] = vis[i][j] + 1 ;
                }
             }
        }
    }
    cout << ans << endl ;
    return 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 5400 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 7 ms 4940 KB Output is correct
5 Correct 3 ms 2636 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 964 KB Output is correct
10 Correct 2 ms 2124 KB Output is correct
11 Correct 2 ms 1988 KB Output is correct
12 Correct 4 ms 2892 KB Output is correct
13 Correct 3 ms 2636 KB Output is correct
14 Correct 3 ms 2636 KB Output is correct
15 Correct 10 ms 4984 KB Output is correct
16 Correct 11 ms 5476 KB Output is correct
17 Correct 9 ms 5068 KB Output is correct
18 Correct 7 ms 4972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 8392 KB Execution killed with signal 11
2 Correct 34 ms 15712 KB Output is correct
3 Runtime error 13 ms 11084 KB Execution killed with signal 11
4 Correct 63 ms 36756 KB Output is correct
5 Runtime error 12 ms 11980 KB Execution killed with signal 11
6 Runtime error 14 ms 16432 KB Execution killed with signal 11
7 Runtime error 7 ms 8396 KB Execution killed with signal 11
8 Runtime error 6 ms 8360 KB Execution killed with signal 11
9 Correct 1 ms 588 KB Output is correct
10 Incorrect 1 ms 332 KB Output isn't correct
11 Runtime error 6 ms 8408 KB Execution killed with signal 11
12 Correct 1 ms 1356 KB Output is correct
13 Correct 46 ms 15528 KB Output is correct
14 Correct 25 ms 10512 KB Output is correct
15 Correct 19 ms 14940 KB Output is correct
16 Correct 16 ms 6480 KB Output is correct
17 Runtime error 10 ms 9684 KB Execution killed with signal 11
18 Incorrect 67 ms 36808 KB Output isn't correct
19 Correct 70 ms 34500 KB Output is correct
20 Correct 49 ms 23928 KB Output is correct
21 Runtime error 13 ms 9544 KB Execution killed with signal 11
22 Runtime error 14 ms 9560 KB Execution killed with signal 11
23 Runtime error 12 ms 9676 KB Execution killed with signal 11
24 Runtime error 16 ms 9420 KB Execution killed with signal 11
25 Runtime error 13 ms 9548 KB Execution killed with signal 11
26 Runtime error 13 ms 9764 KB Execution killed with signal 11
27 Runtime error 15 ms 16372 KB Execution killed with signal 11
28 Runtime error 17 ms 16356 KB Execution killed with signal 11
29 Runtime error 17 ms 16420 KB Execution killed with signal 11
30 Runtime error 15 ms 16368 KB Execution killed with signal 11
31 Runtime error 11 ms 8396 KB Execution killed with signal 11
32 Runtime error 15 ms 16436 KB Execution killed with signal 11