Submission #743737

# Submission time Handle Problem Language Result Execution time Memory
743737 2023-05-17T20:11:52 Z Azm1t Tracks in the Snow (BOI13_tracks) C++17
0 / 100
646 ms 162392 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 + rand()%2 << ed;

    
}
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 924 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Incorrect 7 ms 1236 KB Output isn't correct
5 Incorrect 3 ms 468 KB Output isn't correct
6 Incorrect 1 ms 328 KB Output isn't correct
7 Incorrect 0 ms 212 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 3 ms 460 KB Output isn't correct
11 Incorrect 2 ms 596 KB Output isn't correct
12 Incorrect 5 ms 588 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 10 ms 816 KB Output isn't correct
16 Incorrect 13 ms 860 KB Output isn't correct
17 Incorrect 9 ms 724 KB Output isn't correct
18 Incorrect 8 ms 1236 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Output isn't correct
2 Incorrect 43 ms 2392 KB Output isn't correct
3 Incorrect 302 ms 18380 KB Output isn't correct
4 Incorrect 70 ms 4820 KB Output isn't correct
5 Incorrect 205 ms 10512 KB Output isn't correct
6 Incorrect 646 ms 58392 KB Output isn't correct
7 Incorrect 2 ms 596 KB Output isn't correct
8 Incorrect 2 ms 596 KB Output isn't correct
9 Incorrect 2 ms 468 KB Output isn't correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Incorrect 1 ms 596 KB Output isn't correct
12 Incorrect 1 ms 340 KB Output isn't correct
13 Incorrect 45 ms 2380 KB Output isn't correct
14 Incorrect 25 ms 1508 KB Output isn't correct
15 Incorrect 20 ms 1492 KB Output isn't correct
16 Incorrect 21 ms 1200 KB Output isn't correct
17 Incorrect 108 ms 5232 KB Output isn't correct
18 Incorrect 75 ms 5088 KB Output isn't correct
19 Incorrect 72 ms 4732 KB Output isn't correct
20 Incorrect 78 ms 4428 KB Output isn't correct
21 Incorrect 183 ms 10972 KB Output isn't correct
22 Incorrect 213 ms 10604 KB Output isn't correct
23 Incorrect 220 ms 9332 KB Output isn't correct
24 Incorrect 183 ms 10720 KB Output isn't correct
25 Incorrect 408 ms 18248 KB Output isn't correct
26 Incorrect 476 ms 162392 KB Output isn't correct
27 Incorrect 569 ms 96716 KB Output isn't correct
28 Incorrect 625 ms 58212 KB Output isn't correct
29 Incorrect 616 ms 53600 KB Output isn't correct
30 Incorrect 591 ms 70556 KB Output isn't correct
31 Incorrect 463 ms 13008 KB Output isn't correct
32 Incorrect 524 ms 63704 KB Output isn't correct