Submission #1091838

# Submission time Handle Problem Language Result Execution time Memory
1091838 2024-09-22T10:22:51 Z Jakub_Wozniak Tracks in the Snow (BOI13_tracks) C++14
0 / 100
2 ms 956 KB
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
const int maxn = 4009;
typedef long long ll;
int N , M;
string s[maxn];
string SA;
int a , b , c;
vector <pair<int,int>> R;
bool vis[maxn][maxn];
int MAXI = 0;

void pr()
{
    R.push_back({-1,0});
    R.push_back({1,0});
    R.push_back({0,1});
    R.push_back({0,-1});
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;
    for(int i = 0 ; i <= M+1 ; i++)SA.push_back( '.');
    s[0] = SA;
    s[N+1] = SA;


    pr();
    for(int i = 1 ; i <= N  ;i++)
    {
        scanf("%s", &SA);
        s[i] = '.';
        s[i] += SA;
        s[i].push_back('.');
    }

    priority_queue <pair<int,int>> q;
    pair<int,int> DS;
    q.push({-1,1*maxn+1});
    int i , j;
    vis[1][1] = 1;

    while(!q.empty())
    {
        DS = q.top();
        c = -DS.first; 
        i = DS.second/maxn;
        j = DS.second%maxn;
        q.pop();
        
        MAXI = max(MAXI , c);

        for(int k = 0 ; k < R.size() ; k++)
        {
            a = i+R[k].first;
            b = j+R[k].second;
            if(s[a][b] == '.' || vis[a][b])continue;
            vis[a][b] = 1;
            if(s[a][b] == s[i][j]){ q.push({-c,a*maxn+b});}
            else {q.push({-(c+1),a*maxn+b});}
        }
    }

    cout << MAXI << '\n';


    return 0;
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:35:17: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'std::string*' {aka 'std::__cxx11::basic_string<char>*'} [-Wformat=]
   35 |         scanf("%s", &SA);
      |                ~^   ~~~
      |                 |   |
      |                 |   std::string* {aka std::__cxx11::basic_string<char>*}
      |                 char*
tracks.cpp:57:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for(int k = 0 ; k < R.size() ; k++)
      |                         ~~^~~~~~~~~~
tracks.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         scanf("%s", &SA);
      |         ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 11
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 604 KB Output isn't correct
4 Runtime error 1 ms 860 KB Execution killed with signal 11
5 Runtime error 1 ms 856 KB Execution killed with signal 11
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 604 KB Output isn't correct
8 Incorrect 0 ms 604 KB Output isn't correct
9 Runtime error 1 ms 860 KB Execution killed with signal 11
10 Runtime error 1 ms 860 KB Execution killed with signal 11
11 Runtime error 2 ms 956 KB Execution killed with signal 6
12 Runtime error 1 ms 860 KB Execution killed with signal 11
13 Runtime error 1 ms 860 KB Execution killed with signal 11
14 Runtime error 1 ms 860 KB Execution killed with signal 11
15 Runtime error 1 ms 860 KB Execution killed with signal 11
16 Runtime error 1 ms 860 KB Execution killed with signal 11
17 Runtime error 1 ms 860 KB Execution killed with signal 11
18 Runtime error 1 ms 856 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 11
2 Runtime error 1 ms 860 KB Execution killed with signal 11
3 Runtime error 2 ms 856 KB Execution killed with signal 11
4 Runtime error 1 ms 860 KB Execution killed with signal 11
5 Runtime error 1 ms 860 KB Execution killed with signal 11
6 Runtime error 1 ms 860 KB Execution killed with signal 11
7 Runtime error 1 ms 860 KB Execution killed with signal 11
8 Runtime error 1 ms 860 KB Execution killed with signal 11
9 Runtime error 1 ms 860 KB Execution killed with signal 11
10 Runtime error 1 ms 860 KB Execution killed with signal 11
11 Runtime error 1 ms 860 KB Execution killed with signal 11
12 Runtime error 1 ms 856 KB Execution killed with signal 11
13 Runtime error 1 ms 856 KB Execution killed with signal 11
14 Runtime error 1 ms 856 KB Execution killed with signal 11
15 Runtime error 1 ms 856 KB Execution killed with signal 11
16 Runtime error 1 ms 860 KB Execution killed with signal 11
17 Runtime error 1 ms 860 KB Execution killed with signal 11
18 Runtime error 1 ms 860 KB Execution killed with signal 11
19 Runtime error 1 ms 860 KB Execution killed with signal 11
20 Runtime error 1 ms 860 KB Execution killed with signal 11
21 Runtime error 1 ms 860 KB Execution killed with signal 11
22 Runtime error 1 ms 860 KB Execution killed with signal 11
23 Runtime error 1 ms 860 KB Execution killed with signal 11
24 Runtime error 1 ms 856 KB Execution killed with signal 11
25 Runtime error 1 ms 860 KB Execution killed with signal 11
26 Runtime error 1 ms 860 KB Execution killed with signal 11
27 Runtime error 1 ms 860 KB Execution killed with signal 11
28 Runtime error 1 ms 860 KB Execution killed with signal 11
29 Runtime error 1 ms 860 KB Execution killed with signal 11
30 Runtime error 1 ms 856 KB Execution killed with signal 11
31 Runtime error 1 ms 860 KB Execution killed with signal 11
32 Runtime error 1 ms 860 KB Execution killed with signal 11