# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
927184 | haru09 | Tracks in the Snow (BOI13_tracks) | C++17 | 538 ms | 132520 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define task "code"
const int ar=4e3+5;
const ll mod=1e9+7;
int m,n;
int a[ar][ar];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
deque<pair<int,int>> qu;
bool vs[ar][ar];
int ans=0;
void bfs()
{
qu.push_back({1,1});
vs[1][1]=true;
int last=0;
while(qu.size())
{
pair<int,int> p=qu.front();
qu.pop_front();
int u=p.fi;
int v=p.se;
if (a[u][v]!=last) ans++;
last=a[u][v];
for (int i=0;i<=3;i++)
{
int x=u+dx[i];
int y=v+dy[i];
if (x<1 || x>m || y<1 || y>n) continue;
if (a[x][y]==0) continue;
if (vs[x][y]) continue;
if (a[x][y]==a[u][v])
{
qu.push_front({x,y});
}
else qu.push_back({x,y});
vs[x][y]=true;
}
}
cout<<ans;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if (fopen(task".inp","r"))
{
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
cin>>m>>n;
for (int i=1;i<=m;i++)
{
for (int j=1;j<=n;j++)
{
char x;
cin>>x;
if (x=='.') a[i][j]=0;
else if (x=='R') a[i][j]=1;
else a[i][j]=2;
}
}
bfs();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |