답안 #48708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48708 2018-05-18T08:35:38 Z Extazy Tracks in the Snow (BOI13_tracks) C++17
15.5208 / 100
2000 ms 603512 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;!found && i<=n;i++) {
      for(j=1;!found && 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 218 ms 13816 KB Output is correct
2 Incorrect 3 ms 13816 KB Output isn't correct
3 Incorrect 3 ms 13816 KB Output isn't correct
4 Correct 24 ms 13816 KB Output is correct
5 Incorrect 88 ms 13816 KB Output isn't correct
6 Incorrect 2 ms 13816 KB Output isn't correct
7 Incorrect 3 ms 13816 KB Output isn't correct
8 Correct 3 ms 13816 KB Output is correct
9 Incorrect 6 ms 13816 KB Output isn't correct
10 Incorrect 49 ms 13816 KB Output isn't correct
11 Correct 10 ms 13816 KB Output is correct
12 Correct 57 ms 13816 KB Output is correct
13 Incorrect 68 ms 13816 KB Output isn't correct
14 Incorrect 65 ms 13816 KB Output isn't correct
15 Correct 395 ms 13816 KB Output is correct
16 Correct 211 ms 13948 KB Output is correct
17 Incorrect 452 ms 13948 KB Output isn't correct
18 Correct 30 ms 13948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1078 ms 31296 KB Output isn't correct
2 Execution timed out 2070 ms 31296 KB Time limit exceeded
3 Execution timed out 2067 ms 32380 KB Time limit exceeded
4 Execution timed out 2041 ms 32380 KB Time limit exceeded
5 Execution timed out 2067 ms 32380 KB Time limit exceeded
6 Execution timed out 2085 ms 313348 KB Time limit exceeded
7 Incorrect 1597 ms 313348 KB Output isn't correct
8 Incorrect 1094 ms 313348 KB Output isn't correct
9 Incorrect 105 ms 313348 KB Output isn't correct
10 Incorrect 260 ms 313348 KB Output isn't correct
11 Incorrect 863 ms 313348 KB Output isn't correct
12 Incorrect 148 ms 313348 KB Output isn't correct
13 Execution timed out 2074 ms 313348 KB Time limit exceeded
14 Execution timed out 2078 ms 313348 KB Time limit exceeded
15 Execution timed out 2063 ms 313348 KB Time limit exceeded
16 Execution timed out 2060 ms 313348 KB Time limit exceeded
17 Execution timed out 2070 ms 313348 KB Time limit exceeded
18 Execution timed out 2069 ms 313348 KB Time limit exceeded
19 Execution timed out 2070 ms 313348 KB Time limit exceeded
20 Execution timed out 2081 ms 313348 KB Time limit exceeded
21 Execution timed out 2064 ms 313348 KB Time limit exceeded
22 Execution timed out 2064 ms 313348 KB Time limit exceeded
23 Execution timed out 2067 ms 313348 KB Time limit exceeded
24 Execution timed out 2063 ms 313348 KB Time limit exceeded
25 Execution timed out 2081 ms 313348 KB Time limit exceeded
26 Correct 1084 ms 603512 KB Output is correct
27 Execution timed out 2101 ms 603512 KB Time limit exceeded
28 Execution timed out 2098 ms 603512 KB Time limit exceeded
29 Execution timed out 2102 ms 603512 KB Time limit exceeded
30 Execution timed out 2080 ms 603512 KB Time limit exceeded
31 Execution timed out 2073 ms 603512 KB Time limit exceeded
32 Execution timed out 2083 ms 603512 KB Time limit exceeded