답안 #1020063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020063 2024-07-11T13:24:41 Z 7again Tracks in the Snow (BOI13_tracks) C++17
0 / 100
2000 ms 164764 KB
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define FAST ios::sync_with_stdio(0);cout.tie(0);cin.tie(0)

using namespace std ;

void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}

const int N = 6e3 , MOD = 1e9+7 ;
int xis[4]{1 , -1 , 0 , 0} , yis[4]{0 , 0 , 1 , -1} ;

int n , m ;
char a[N][N] ;
vector <int> v[N] ;

bool inside(int x , int y)
{
    return (x < n && x > -1 && y < m && y > -1 && a[x][y] != '.') ;
}
void slv()
{
    cin >> n >> m ;
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < m ; j++)
            cin >> a[i][j] ;

    int depth[n][m]{0} ;
    deque <pair <int , int>> q ;
    q.push_back({0 , 0}) ;
    depth[0][0] = 1 ;
    int mx = 1 ;

    while(q.size())
    {
        pair <int , int> t = q.front() ;
        q.pop_front() ;

        mx = max(mx , depth[t.f][t.s]) ;

        for(int i = 0 ; i < 4 ; i++)
        {
            int x = t.f + xis[i] , y = t.s = yis[i] ;
            if(inside(x , y) && depth[x][y] == 0)
            {
                if(a[x][y] == a[t.f][t.s])
                {
                    depth[x][y] = depth[t.f][t.s] ;
                    q.push_front({x , y}) ;
                }
                else
                {
                    depth[x][y] = depth[t.f][t.s] + 1 ;
                    q.push_back({x , y}) ;
                }
            }
        }
    }


    cout << mx + 1 ;
}
main()
{
    FAST ;

    slv() ;
}

Compilation message

tracks.cpp:65:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   65 | main()
      | ^~~~
tracks.cpp: In function 'void setIO(std::string)':
tracks.cpp:10:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:10:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2043 ms 7000 KB Time limit exceeded
2 Execution timed out 2060 ms 2652 KB Time limit exceeded
3 Execution timed out 2055 ms 2652 KB Time limit exceeded
4 Execution timed out 2040 ms 5976 KB Time limit exceeded
5 Execution timed out 2036 ms 3160 KB Time limit exceeded
6 Execution timed out 2035 ms 2648 KB Time limit exceeded
7 Execution timed out 2025 ms 2648 KB Time limit exceeded
8 Execution timed out 2052 ms 2648 KB Time limit exceeded
9 Execution timed out 2061 ms 2648 KB Time limit exceeded
10 Execution timed out 2044 ms 3160 KB Time limit exceeded
11 Execution timed out 2027 ms 2904 KB Time limit exceeded
12 Execution timed out 2062 ms 3420 KB Time limit exceeded
13 Execution timed out 2083 ms 3160 KB Time limit exceeded
14 Execution timed out 2060 ms 3164 KB Time limit exceeded
15 Execution timed out 2064 ms 5212 KB Time limit exceeded
16 Execution timed out 2065 ms 6636 KB Time limit exceeded
17 Execution timed out 2064 ms 5212 KB Time limit exceeded
18 Execution timed out 2045 ms 4440 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2049 ms 16984 KB Time limit exceeded
2 Execution timed out 2040 ms 21080 KB Time limit exceeded
3 Execution timed out 2079 ms 149080 KB Time limit exceeded
4 Execution timed out 2073 ms 43028 KB Time limit exceeded
5 Execution timed out 2052 ms 97384 KB Time limit exceeded
6 Execution timed out 2049 ms 157280 KB Time limit exceeded
7 Execution timed out 2068 ms 16988 KB Time limit exceeded
8 Execution timed out 2068 ms 16220 KB Time limit exceeded
9 Execution timed out 2043 ms 1116 KB Time limit exceeded
10 Execution timed out 2035 ms 856 KB Time limit exceeded
11 Execution timed out 2032 ms 16984 KB Time limit exceeded
12 Execution timed out 2028 ms 1368 KB Time limit exceeded
13 Execution timed out 2071 ms 20832 KB Time limit exceeded
14 Execution timed out 2055 ms 12892 KB Time limit exceeded
15 Execution timed out 2027 ms 14168 KB Time limit exceeded
16 Execution timed out 2050 ms 8448 KB Time limit exceeded
17 Execution timed out 2037 ms 47952 KB Time limit exceeded
18 Execution timed out 2041 ms 47440 KB Time limit exceeded
19 Execution timed out 2017 ms 44880 KB Time limit exceeded
20 Execution timed out 2079 ms 41044 KB Time limit exceeded
21 Execution timed out 2016 ms 100688 KB Time limit exceeded
22 Execution timed out 2059 ms 97204 KB Time limit exceeded
23 Execution timed out 2051 ms 83312 KB Time limit exceeded
24 Execution timed out 2089 ms 98564 KB Time limit exceeded
25 Execution timed out 2058 ms 164424 KB Time limit exceeded
26 Execution timed out 2070 ms 128852 KB Time limit exceeded
27 Execution timed out 2062 ms 164764 KB Time limit exceeded
28 Execution timed out 2045 ms 164432 KB Time limit exceeded
29 Execution timed out 2039 ms 164688 KB Time limit exceeded
30 Execution timed out 2079 ms 161360 KB Time limit exceeded
31 Execution timed out 2064 ms 109464 KB Time limit exceeded
32 Execution timed out 2050 ms 164688 KB Time limit exceeded