# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
42407 | Hassoony | Tracks in the Snow (BOI13_tracks) | C++14 | 2122 ms | 1003268 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<unordered_map>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double D;
const ll inf=(1ll<<61);
const ll mod=1e9+7;
const int MX=4002;
int n,m,cnt,h;
bool vis[MX][MX];
char a[MX][MX],c;
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
vector<pair<int,int> >nodes;
void dfs(int x,int y){
if(vis[x][y])return;
vis[x][y]=1;
cnt++;
for(int i=0;i<4;i++){
int nx=dx[i]+x,ny=dy[i]+y;
if(nx>=n||ny>=m||nx<0||ny<0||a[nx][ny]!=a[x][y])continue;
dfs(nx,ny);
}
a[x][y]=c;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)scanf("%s",&a[i]);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(a[i][j]!='.')h++;
}
}
int ans=0;
while(cnt!=h){
c='R';
if(a[0][0]=='R')c='F';
cnt=0;
dfs(0,0);
ans++;
memset(vis,0,sizeof(vis));
}
cout<<ans<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |