Submission #907452

# Submission time Handle Problem Language Result Execution time Memory
907452 2024-01-15T15:44:53 Z arnavai Tracks in the Snow (BOI13_tracks) C++14
0 / 100
2000 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define inf 1000000007
#define llmax LLONG_MAX
#define pi 3.141592653589793238462643383279502884197169399
 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll ncr(int n, int r)
{
    if (n < r) return 0;
    long long p = 1, k = 1;
    if (n - r < r)
        r = n - r;
    if (r != 0) {
        while (r) {
            p *= n;
            k *= r;
            long long m = __gcd(p, k);
            p /= m;
            k /= m;
            n--;
            r--;
        }
    }
    else
        p = 1;
    return p;
}

vector <ll> vcreate(int n){
    vector <ll> v(n);
    for (int i = 0; i < n; i++)
    {
        cin>>v[i];
    }
    return v;
}

bool dfs(vector<vector<char>>&v, char z, int x, int y)
{
    bool flag = false;
    char find;
    if(z=='R') 
    {
        v[x][y]='F';
        find='R';
    }
    else
    {
        v[x][y]='R';
        find = 'F';
    }
    int h = v.size();
    int w = v[0].size();
    int dx[] = {-1, 1, 0, 0};
    int dy[] = {0,0,-1,1};
    for(int i = 0; i<4; i++)
    {
        if(x+dx[i]>=0 and x+dx[i]<h and y+dy[i]>=0 and y+dy[i]<w and v[x+dx[i]][y+dy[i]]==v[x][y]) flag = true;
        if(x+dx[i]>=0 and x+dx[i]<h and y+dy[i]>=0 and y+dy[i]<w and v[x+dx[i]][y+dy[i]]==find)
        {
            dfs(v, z, x+dx[i], y+dy[i]);
        }
        
    }
    return flag;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout); 

    int h, w; cin>>h>>w;
    vector<vector<char>>v(h, vector<char>(w));
    for(int i = 0; i<h; i++)
    {
        for(int j = 0; j<w; j++)
        {
            cin>>v[i][j];
        }
    }
    int ans = 1;
    while(true)
    {
        char z = v[0][0];
        bool x = dfs(v, z, 0, 0);
        ans++;
        if(!x) break;
    }
    cout<<ans<<'\n';

}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1116 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Execution timed out 2082 ms 24660 KB Time limit exceeded
5 Incorrect 1 ms 856 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Execution timed out 2033 ms 1116 KB Time limit exceeded
9 Execution timed out 2024 ms 344 KB Time limit exceeded
10 Incorrect 2 ms 600 KB Output isn't correct
11 Execution timed out 2057 ms 6748 KB Time limit exceeded
12 Execution timed out 2054 ms 10332 KB Time limit exceeded
13 Incorrect 2 ms 600 KB Output isn't correct
14 Incorrect 2 ms 600 KB Output isn't correct
15 Incorrect 3 ms 1116 KB Output isn't correct
16 Incorrect 3 ms 1116 KB Output isn't correct
17 Incorrect 3 ms 1200 KB Output isn't correct
18 Execution timed out 2064 ms 24660 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1116 KB Output isn't correct
2 Incorrect 16 ms 3920 KB Output isn't correct
3 Incorrect 151 ms 33124 KB Output isn't correct
4 Incorrect 36 ms 8276 KB Output isn't correct
5 Incorrect 87 ms 19044 KB Output isn't correct
6 Execution timed out 2112 ms 1041380 KB Time limit exceeded
7 Incorrect 2 ms 1112 KB Output isn't correct
8 Incorrect 2 ms 1116 KB Output isn't correct
9 Incorrect 2 ms 1372 KB Output isn't correct
10 Incorrect 1 ms 1112 KB Output isn't correct
11 Incorrect 1 ms 1236 KB Output isn't correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Incorrect 15 ms 3932 KB Output isn't correct
14 Incorrect 10 ms 2380 KB Output isn't correct
15 Incorrect 10 ms 2652 KB Output isn't correct
16 Execution timed out 2064 ms 12768 KB Time limit exceeded
17 Incorrect 38 ms 9052 KB Output isn't correct
18 Incorrect 38 ms 8788 KB Output isn't correct
19 Incorrect 36 ms 8640 KB Output isn't correct
20 Incorrect 33 ms 7568 KB Output isn't correct
21 Incorrect 99 ms 19648 KB Output isn't correct
22 Incorrect 86 ms 19056 KB Output isn't correct
23 Execution timed out 2017 ms 38960 KB Time limit exceeded
24 Incorrect 90 ms 19020 KB Output isn't correct
25 Incorrect 160 ms 33004 KB Output isn't correct
26 Runtime error 836 ms 1048576 KB Execution killed with signal 9
27 Runtime error 1617 ms 1048576 KB Execution killed with signal 9
28 Execution timed out 2111 ms 1042324 KB Time limit exceeded
29 Execution timed out 2185 ms 1048576 KB Time limit exceeded
30 Runtime error 1695 ms 1048576 KB Execution killed with signal 9
31 Incorrect 98 ms 21972 KB Output isn't correct
32 Runtime error 1117 ms 1048576 KB Execution killed with signal 9