# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1020049 | 7again | Tracks in the Snow (BOI13_tracks) | C++17 | 2096 ms | 1048576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 = 2e5 , MOD = 1e9+7 ;
int xis[4]{1 , -1 , 0 , 0} , yis[4]{0 , 0 , 1 , -1} ;
int n , m ;
vector <int> v[N] ;
bool inside(int x , int y)
{
return (x < n && x > -1 && y < m && y > -1) ;
}
void slv()
{
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] ;
int depth[n][m]{0} ;
deque <pair <int , int>> q ;
q.push_back({0 , 0}) ;
depth[0][0] = 0 ;
int mx = 1 ;
while(!q.empty())
{
pair <int , int> t = q.front() ;
q.pop_back() ;
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_back({x , y}) ;
}
else
{
depth[x][y] = depth[t.f][t.s] + 1 ;
q.push_front({x , y}) ;
}
}
}
}
cout << mx ;
}
main()
{
//FAST ;
slv() ;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |