Submission #48706

# Submission time Handle Problem Language Result Execution time Memory
48706 2018-05-18T08:21:38 Z Extazy Tracks in the Snow (BOI13_tracks) C++17
15.5208 / 100
2000 ms 629584 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];

  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';
      }
    }
  }

  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);
     ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 192 ms 13944 KB Output is correct
2 Incorrect 2 ms 13944 KB Output isn't correct
3 Incorrect 3 ms 13944 KB Output isn't correct
4 Correct 35 ms 13944 KB Output is correct
5 Incorrect 62 ms 13944 KB Output isn't correct
6 Incorrect 2 ms 13944 KB Output isn't correct
7 Incorrect 3 ms 13944 KB Output isn't correct
8 Correct 3 ms 13944 KB Output is correct
9 Incorrect 4 ms 13944 KB Output isn't correct
10 Incorrect 51 ms 13944 KB Output isn't correct
11 Correct 7 ms 13944 KB Output is correct
12 Correct 54 ms 13944 KB Output is correct
13 Incorrect 62 ms 13944 KB Output isn't correct
14 Incorrect 62 ms 13944 KB Output isn't correct
15 Correct 424 ms 13944 KB Output is correct
16 Correct 182 ms 15176 KB Output is correct
17 Incorrect 437 ms 15176 KB Output isn't correct
18 Correct 24 ms 15176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 797 ms 32832 KB Output isn't correct
2 Execution timed out 2069 ms 32832 KB Time limit exceeded
3 Execution timed out 2054 ms 39280 KB Time limit exceeded
4 Execution timed out 2076 ms 39280 KB Time limit exceeded
5 Execution timed out 2075 ms 39696 KB Time limit exceeded
6 Execution timed out 2086 ms 341244 KB Time limit exceeded
7 Incorrect 1252 ms 341244 KB Output isn't correct
8 Incorrect 811 ms 341244 KB Output isn't correct
9 Incorrect 98 ms 341244 KB Output isn't correct
10 Incorrect 239 ms 341244 KB Output isn't correct
11 Incorrect 768 ms 341244 KB Output isn't correct
12 Incorrect 7 ms 341244 KB Output isn't correct
13 Execution timed out 2045 ms 341244 KB Time limit exceeded
14 Execution timed out 2072 ms 341244 KB Time limit exceeded
15 Execution timed out 2068 ms 341244 KB Time limit exceeded
16 Execution timed out 2059 ms 341244 KB Time limit exceeded
17 Execution timed out 2070 ms 341244 KB Time limit exceeded
18 Execution timed out 2076 ms 341244 KB Time limit exceeded
19 Execution timed out 2053 ms 341244 KB Time limit exceeded
20 Execution timed out 2051 ms 341244 KB Time limit exceeded
21 Execution timed out 2074 ms 341244 KB Time limit exceeded
22 Execution timed out 2067 ms 341244 KB Time limit exceeded
23 Execution timed out 2080 ms 341244 KB Time limit exceeded
24 Execution timed out 2071 ms 341244 KB Time limit exceeded
25 Execution timed out 2079 ms 341244 KB Time limit exceeded
26 Correct 1101 ms 629584 KB Output is correct
27 Execution timed out 2109 ms 629584 KB Time limit exceeded
28 Execution timed out 2104 ms 629584 KB Time limit exceeded
29 Execution timed out 2102 ms 629584 KB Time limit exceeded
30 Execution timed out 2103 ms 629584 KB Time limit exceeded
31 Execution timed out 2091 ms 629584 KB Time limit exceeded
32 Execution timed out 2079 ms 629584 KB Time limit exceeded