답안 #743736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743736 2023-05-17T20:10:28 Z Azm1t Tracks in the Snow (BOI13_tracks) C++17
0 / 100
666 ms 162900 KB
#include "bits/stdc++.h"
using namespace std;
#define forn for (int i = 0; i < n; i++)
#define int long long
#define ed "\n"
#define cyes cout << "YES\n"
#define cno cout << "NO\n"
#define pb push_back
#define deb cout << "Hi\n"
#define pint pair<int, int>
const long long MOD = 1000000007;

void dbg_out(){cerr<<"\n";}
template<typename Head,typename... Tail>
void dbg_out(Head H,Tail... T){cerr<<' '<<H;dbg_out(T...);}
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dbg_out(__VA_ARGS__)

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------//


int32_t main(){

    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m; cin>>n>>m;
    char a[n][m];
    for(int i = 0; i < n; i++){
        for(int j = 0 ; j < m; j++){
            cin>>a[i][j];
        }
    }

    char cur = a[0][0];
    vector<vector<bool>> vis(n, vector<bool>(m, false));
    deque<pair<pint, char>> d;
    d.pb({{0, 0}, cur});

    auto valid = [&](int i, int j){
        return(i < n && i >= 0 && j < m && j >= 0);
    };

    vector<pint> moves = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
    int ans = 1;
    // int t = 0;

    while(!d.empty()){
        // cout << ++t << ed;
        auto c = d.front();
        d.pop_front();
        int i = c.first.first;
        int j = c.first.second;
        char x = c.second;
        if(x != cur){
            cur = x;
            ans++;
        }

        for(auto val: moves){
            int nx = i + val.first;
            int ny = j + val.second;
            char y;
            if(x == 'F') y = 'R';
            else y = 'F';
            if(valid(nx, ny) && !vis[nx][ny] && a[nx][ny] != '.'){
                if(x == a[nx][ny]) d.push_front({{nx, ny}, x});
                else d.push_back({{nx, ny}, y});
                vis[nx][ny] = true;
            }  
        }
        

    }

    cout << ans + 1 << ed;

    
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 1040 KB Output isn't correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Incorrect 6 ms 1260 KB Output isn't correct
5 Incorrect 3 ms 468 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 320 KB Output isn't correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 2 ms 468 KB Output isn't correct
11 Incorrect 3 ms 596 KB Output isn't correct
12 Incorrect 5 ms 596 KB Output isn't correct
13 Incorrect 3 ms 468 KB Output isn't correct
14 Incorrect 2 ms 468 KB Output isn't correct
15 Incorrect 11 ms 928 KB Output isn't correct
16 Incorrect 12 ms 912 KB Output isn't correct
17 Incorrect 11 ms 840 KB Output isn't correct
18 Incorrect 6 ms 1220 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 672 KB Output isn't correct
2 Incorrect 47 ms 3100 KB Output isn't correct
3 Incorrect 307 ms 19140 KB Output isn't correct
4 Incorrect 81 ms 5556 KB Output isn't correct
5 Incorrect 206 ms 11372 KB Output isn't correct
6 Incorrect 638 ms 59224 KB Output isn't correct
7 Incorrect 2 ms 596 KB Output isn't correct
8 Incorrect 2 ms 588 KB Output isn't correct
9 Incorrect 2 ms 468 KB Output isn't correct
10 Incorrect 1 ms 332 KB Output isn't correct
11 Incorrect 2 ms 596 KB Output isn't correct
12 Incorrect 1 ms 376 KB Output isn't correct
13 Incorrect 48 ms 3148 KB Output isn't correct
14 Incorrect 29 ms 2252 KB Output isn't correct
15 Incorrect 23 ms 2428 KB Output isn't correct
16 Incorrect 22 ms 1692 KB Output isn't correct
17 Incorrect 123 ms 5984 KB Output isn't correct
18 Incorrect 91 ms 5840 KB Output isn't correct
19 Incorrect 71 ms 5500 KB Output isn't correct
20 Incorrect 74 ms 5192 KB Output isn't correct
21 Incorrect 187 ms 11648 KB Output isn't correct
22 Incorrect 215 ms 11340 KB Output isn't correct
23 Incorrect 235 ms 10096 KB Output isn't correct
24 Incorrect 188 ms 11496 KB Output isn't correct
25 Incorrect 355 ms 19152 KB Output isn't correct
26 Incorrect 516 ms 162900 KB Output isn't correct
27 Incorrect 607 ms 97668 KB Output isn't correct
28 Incorrect 658 ms 59120 KB Output isn't correct
29 Incorrect 666 ms 54664 KB Output isn't correct
30 Incorrect 618 ms 71668 KB Output isn't correct
31 Incorrect 482 ms 14048 KB Output isn't correct
32 Incorrect 537 ms 64344 KB Output isn't correct