답안 #553766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
553766 2022-04-26T21:43:46 Z Uzouf Tracks in the Snow (BOI13_tracks) C++14
0 / 100
2000 ms 10264 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
//#define endl "\n"
const int mod = (int) 1e9 + 7;
const int N=1005;

int n,m,ans,nm;
char c,tmp;
char v[N][N];
char imp[N][N];
bool vis[N][N];
bool bl;

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

bool chk(int i,int j) {
  return i>=0 && j>=0 && i<n && j<m && !vis[i][j] && v[i][j]==tmp && imp[i][j]!='*';
}

void bfs(int a,int b) {
  queue<pair<int,int> > q; q.push({a,b});
  while (!q.empty()) {
    int i=q.front().first;
    int j=q.front().second;
    q.pop();
    vis[i][j]=true;

    for (int p=0;p<4;p++) {
      int ii=i+dx[p],jj=j+dy[p];
      if (chk(ii,jj)) {
      nm--; bl=true; bfs(ii,jj);}
    }
  }

}


signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(".in", "r", stdin); freopen(".out", "w", stdout);

    cin>>n>>m;
    for (int i=0;i<n;i++) {
      for (int j=0;j<m;j++) {
        cin>>v[i][j];
        if (v[i][j]=='.') {imp[i][j]='*';}
        else {nm++;}
      }
    }

    c=v[0][0]; tmp=v[0][0]; nm--; bfs(0,0); ans++;

    while (nm>0) {
      bl=false;
      for (int i=0;i<n;i++) {
        for (int j=0;j<m;j++) {

          if (vis[i][j] && v[i][j]==c && imp[i][j]!='*') {
            if (c=='R') {tmp='F';}
            else {tmp='R';}
            nm--; bfs(i,j);
            imp[i][j]='*';
          }

        }
      }
      c=tmp;
      if (bl) {ans++;}
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 3028 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 1 ms 468 KB Output isn't correct
4 Incorrect 25 ms 10264 KB Output isn't correct
5 Incorrect 6 ms 1632 KB Output isn't correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 1 ms 468 KB Output isn't correct
8 Incorrect 1 ms 724 KB Output isn't correct
9 Incorrect 1 ms 724 KB Output isn't correct
10 Incorrect 5 ms 1492 KB Output isn't correct
11 Incorrect 8 ms 5332 KB Output isn't correct
12 Incorrect 9 ms 1908 KB Output isn't correct
13 Incorrect 6 ms 1620 KB Output isn't correct
14 Incorrect 6 ms 1724 KB Output isn't correct
15 Incorrect 25 ms 2960 KB Output isn't correct
16 Incorrect 26 ms 3028 KB Output isn't correct
17 Incorrect 22 ms 2772 KB Output isn't correct
18 Incorrect 23 ms 10220 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 4436 KB Execution killed with signal 11
2 Runtime error 22 ms 5844 KB Execution killed with signal 11
3 Runtime error 59 ms 8492 KB Execution killed with signal 11
4 Runtime error 35 ms 6660 KB Execution killed with signal 11
5 Runtime error 46 ms 7628 KB Execution killed with signal 11
6 Runtime error 56 ms 6400 KB Execution killed with signal 11
7 Runtime error 4 ms 4436 KB Execution killed with signal 11
8 Runtime error 4 ms 4432 KB Execution killed with signal 11
9 Execution timed out 2077 ms 596 KB Time limit exceeded
10 Execution timed out 2083 ms 1108 KB Time limit exceeded
11 Runtime error 3 ms 4444 KB Execution killed with signal 11
12 Incorrect 101 ms 1004 KB Output isn't correct
13 Runtime error 20 ms 5844 KB Execution killed with signal 11
14 Incorrect 123 ms 5388 KB Output isn't correct
15 Execution timed out 2073 ms 5708 KB Time limit exceeded
16 Execution timed out 2083 ms 1744 KB Time limit exceeded
17 Runtime error 31 ms 6524 KB Execution killed with signal 11
18 Runtime error 39 ms 6568 KB Execution killed with signal 11
19 Runtime error 36 ms 6568 KB Execution killed with signal 11
20 Runtime error 30 ms 6552 KB Execution killed with signal 11
21 Runtime error 44 ms 7584 KB Execution killed with signal 11
22 Runtime error 45 ms 7636 KB Execution killed with signal 11
23 Runtime error 46 ms 7612 KB Execution killed with signal 11
24 Runtime error 46 ms 7508 KB Execution killed with signal 11
25 Runtime error 76 ms 8360 KB Execution killed with signal 11
26 Runtime error 50 ms 5964 KB Execution killed with signal 11
27 Runtime error 54 ms 6196 KB Execution killed with signal 11
28 Runtime error 56 ms 6552 KB Execution killed with signal 11
29 Runtime error 59 ms 5680 KB Execution killed with signal 11
30 Runtime error 56 ms 6096 KB Execution killed with signal 11
31 Runtime error 46 ms 7684 KB Execution killed with signal 11
32 Runtime error 58 ms 8336 KB Execution killed with signal 11