답안 #1099373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099373 2024-10-11T08:50:45 Z YFHHFY Tracks in the Snow (BOI13_tracks) C++14
22.1875 / 100
4 ms 3936 KB
#include<bits/stdc++.h>
#define tizoboz ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
// #define int long long
#define itn int
#define ss set <int>
#define prq priority_queue <int>
#define endl '\n'
const ll MOD = 1e9 + 7;
#define md(x) (((x%MOD)+MOD)%MOD)
#define vi vector <int>
#define vl vector<ll>
#define str string 
#define mp make_pair
#define mata int32_t
#define sz size
#define lc id *2
#define rc lc +1
#define SZ(x)           (int)x.size()
#define mid (l+r)/2
#define cn cin
#define ct cout
#define sep " "
#define F first
#define X first
#define S second
#define Y second
using namespace std;
typedef pair <int , int> pii;
const ll maxn = 4e2 + 5 ;
const int Lg = 23;
const ll inf = 1e9;
const int dx[] = {-1 , 0 , 1,0}   , dy[] = {0,-1,0,1};
int n , m , d[maxn][maxn];
char a[maxn][maxn];
inline bool check (int x , int y){
    return (1 <= x && x <= n && 1 <= y && y<= m);
}
void solve (){
    cn >> n >> m;
    for (int i =1 ;i<= n ; i++){
        cn >> a[i]+1;
        for (int j = 1 ; j <= m ; j++){
            d[i][j] = inf;
        }
    }
    deque <pair <short  ,short >> q;
    q.pb(mp(1,1));
    d[1][1] = 1;
    while (SZ(q)){
        int x = q.front().F , y = q.front().S;
        q.pop_front();
        for (int i = 0 ; i < 4 ; i++){
            int xx = x + dx[i];
            int yy = y + dy[i];
            if (check(xx , yy) && a[xx][yy] != '.'){
                int val = d[x][y] + (a[x][y] != a[xx][yy]);
                if (d[xx][yy] > val){
                    d[xx][yy] = val;
                    if (a[x][y] == a[xx][yy]){
                        q.push_front(mp(xx,yy));
                    }
                    else{
                        q.pb(mp(xx,yy));
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 1 ; i<= n ; i++){
        for (int j = 1 ; j <= m ; j++){
            if (a[i][j] != '.'){
                ans = max (ans , d[i][j]);
            }
        }
    }
    ct << ans << endl;
}
mata main(){
    tizoboz;
    int tt = 1;
    // cn >> tt;
    while (tt--){
        solve();
    }
    return 0;
}

Compilation message

tracks.cpp: In function 'void solve()':
tracks.cpp:44:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   44 |         cn >> a[i]+1;
      |               ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 2396 KB Execution killed with signal 11
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Runtime error 2 ms 2140 KB Execution killed with signal 11
5 Correct 2 ms 920 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 2 ms 1116 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 2 ms 1116 KB Output is correct
14 Correct 2 ms 1120 KB Output is correct
15 Runtime error 3 ms 2332 KB Execution killed with signal 11
16 Runtime error 3 ms 2436 KB Execution killed with signal 11
17 Runtime error 2 ms 2396 KB Execution killed with signal 11
18 Runtime error 2 ms 2140 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 2008 KB Execution killed with signal 11
2 Runtime error 4 ms 2652 KB Execution killed with signal 11
3 Runtime error 4 ms 3932 KB Execution killed with signal 11
4 Runtime error 3 ms 3020 KB Execution killed with signal 11
5 Runtime error 3 ms 3420 KB Execution killed with signal 11
6 Runtime error 4 ms 3932 KB Execution killed with signal 11
7 Runtime error 1 ms 2140 KB Execution killed with signal 11
8 Runtime error 1 ms 2016 KB Execution killed with signal 11
9 Incorrect 1 ms 476 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Runtime error 1 ms 2144 KB Execution killed with signal 11
12 Correct 1 ms 704 KB Output is correct
13 Runtime error 3 ms 2652 KB Execution killed with signal 11
14 Runtime error 2 ms 2652 KB Execution killed with signal 11
15 Runtime error 4 ms 2652 KB Execution killed with signal 11
16 Incorrect 3 ms 1884 KB Output isn't correct
17 Runtime error 4 ms 3072 KB Execution killed with signal 11
18 Runtime error 3 ms 3016 KB Execution killed with signal 11
19 Runtime error 3 ms 3168 KB Execution killed with signal 11
20 Runtime error 3 ms 3168 KB Execution killed with signal 11
21 Runtime error 4 ms 3424 KB Execution killed with signal 11
22 Runtime error 4 ms 3416 KB Execution killed with signal 11
23 Runtime error 3 ms 3428 KB Execution killed with signal 11
24 Runtime error 4 ms 3424 KB Execution killed with signal 11
25 Runtime error 4 ms 3932 KB Execution killed with signal 11
26 Runtime error 3 ms 3684 KB Execution killed with signal 11
27 Runtime error 4 ms 3880 KB Execution killed with signal 11
28 Runtime error 4 ms 3864 KB Execution killed with signal 11
29 Runtime error 4 ms 3936 KB Execution killed with signal 11
30 Runtime error 4 ms 3936 KB Execution killed with signal 11
31 Runtime error 3 ms 3420 KB Execution killed with signal 11
32 Runtime error 4 ms 3928 KB Execution killed with signal 11