답안 #48707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48707 2018-05-18T08:27:18 Z Extazy Tracks in the Snow (BOI13_tracks) C++17
15.5208 / 100
2000 ms 605464 KB
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int N = 4007;
const pair < int, int > D[4] = {
  make_pair(1,0),
  make_pair(-1,0),
  make_pair(0,1),
  make_pair(0,-1)
};

int n,m;
char a[N][N];
bool used[N][N];
int ans;

void clear_used() {
  int i,j;

  for(i=1;i<=n;i++) {
    for(j=1;j<=m;j++) {
      used[i][j]=false;
    }
  }
}

void dfs(int r, int c, char ch) {
  a[r][c]='#';
  used[r][c]=true;

  int i,p,t;

  for(i=0;i<4;i++) {
    p=r+D[i].first;
    t=c+D[i].second;

    if(p>=1 && p<=n && t>=1 && t<=m) if(!used[p][t]) if(a[p][t]==ch || a[p][t]=='#') dfs(p,t,ch);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i,j;
  char curr;

  scanf("%d %d", &n, &m);
  for(i=1;i<=n;i++) {
    scanf("%s", a[i]+1);
  }

  curr=a[1][1];

  bool found=true;

  while(found) {
    found=false;

    for(i=1;i<=n;i++) {
      for(j=1;j<=m;j++) {
        if(a[i][j]==curr) {
          clear_used();
          dfs(i,j,a[i][j]);
          ++ans;

          if(curr=='R') curr='F';
          else curr='R';
          
          found=true;
        }
      }
    }
  }

  printf("%d\n", ans);

  return 0;
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
tracks.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", a[i]+1);
     ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 226 ms 13992 KB Output is correct
2 Incorrect 2 ms 13992 KB Output isn't correct
3 Incorrect 3 ms 13992 KB Output isn't correct
4 Correct 26 ms 13992 KB Output is correct
5 Incorrect 63 ms 13992 KB Output isn't correct
6 Incorrect 2 ms 13992 KB Output isn't correct
7 Incorrect 3 ms 13992 KB Output isn't correct
8 Correct 3 ms 13992 KB Output is correct
9 Incorrect 5 ms 13992 KB Output isn't correct
10 Incorrect 49 ms 13992 KB Output isn't correct
11 Correct 8 ms 13992 KB Output is correct
12 Correct 57 ms 13992 KB Output is correct
13 Incorrect 66 ms 13992 KB Output isn't correct
14 Incorrect 88 ms 13992 KB Output isn't correct
15 Correct 357 ms 13992 KB Output is correct
16 Correct 181 ms 15296 KB Output is correct
17 Incorrect 431 ms 15296 KB Output isn't correct
18 Correct 27 ms 15296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 850 ms 32960 KB Output isn't correct
2 Execution timed out 2068 ms 32960 KB Time limit exceeded
3 Execution timed out 2078 ms 34200 KB Time limit exceeded
4 Execution timed out 2076 ms 34200 KB Time limit exceeded
5 Execution timed out 2076 ms 34200 KB Time limit exceeded
6 Execution timed out 2087 ms 314988 KB Time limit exceeded
7 Incorrect 1243 ms 314988 KB Output isn't correct
8 Incorrect 838 ms 314988 KB Output isn't correct
9 Incorrect 103 ms 314988 KB Output isn't correct
10 Incorrect 250 ms 314988 KB Output isn't correct
11 Incorrect 728 ms 314988 KB Output isn't correct
12 Incorrect 105 ms 314988 KB Output isn't correct
13 Execution timed out 2071 ms 314988 KB Time limit exceeded
14 Execution timed out 2080 ms 314988 KB Time limit exceeded
15 Execution timed out 2066 ms 314988 KB Time limit exceeded
16 Execution timed out 2081 ms 314988 KB Time limit exceeded
17 Execution timed out 2069 ms 314988 KB Time limit exceeded
18 Execution timed out 2079 ms 314988 KB Time limit exceeded
19 Execution timed out 2048 ms 314988 KB Time limit exceeded
20 Execution timed out 2071 ms 314988 KB Time limit exceeded
21 Execution timed out 2090 ms 314988 KB Time limit exceeded
22 Execution timed out 2064 ms 314988 KB Time limit exceeded
23 Execution timed out 2066 ms 314988 KB Time limit exceeded
24 Execution timed out 2079 ms 314988 KB Time limit exceeded
25 Execution timed out 2072 ms 314988 KB Time limit exceeded
26 Correct 1092 ms 605464 KB Output is correct
27 Execution timed out 2103 ms 605464 KB Time limit exceeded
28 Execution timed out 2082 ms 605464 KB Time limit exceeded
29 Execution timed out 2091 ms 605464 KB Time limit exceeded
30 Execution timed out 2073 ms 605464 KB Time limit exceeded
31 Execution timed out 2089 ms 605464 KB Time limit exceeded
32 Execution timed out 2102 ms 605464 KB Time limit exceeded