답안 #42404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42404 2018-02-26T17:19:40 Z Hassoony Tracks in the Snow (BOI13_tracks) C++14
29.5833 / 100
1258 ms 780872 KB
#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,vis[MX][MX],cnt;
char a[MX][MX];
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
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);
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)scanf("%s",&a[i]);
    char c='R';
    if(a[0][0]=='R')c='F';
    int ans=1;
    dfs(0,0);
    int h=cnt;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(vis[i][j])a[i][j]=c;
        }
    }
    memset(vis,0,sizeof(vis));
    cnt=0;
    dfs(0,0);
    if(cnt!=h)ans++;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(vis[i][j]||a[i][j]=='.')continue;
            dfs(i,j);
            ans++;
        }
    }
    cout<<ans<<endl;
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:27:41: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[4002]' [-Wformat=]
     for(int i=0;i<n;i++)scanf("%s",&a[i]);
                                         ^
tracks.cpp:26:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
tracks.cpp:27:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%s",&a[i]);
                                          ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 76 ms 65400 KB Output isn't correct
2 Correct 50 ms 65400 KB Output is correct
3 Incorrect 51 ms 65400 KB Output isn't correct
4 Incorrect 62 ms 68072 KB Output isn't correct
5 Incorrect 51 ms 68072 KB Output isn't correct
6 Correct 50 ms 68072 KB Output is correct
7 Incorrect 51 ms 68072 KB Output isn't correct
8 Incorrect 50 ms 68072 KB Output isn't correct
9 Incorrect 47 ms 68072 KB Output isn't correct
10 Incorrect 50 ms 68072 KB Output isn't correct
11 Incorrect 53 ms 68072 KB Output isn't correct
12 Incorrect 56 ms 68072 KB Output isn't correct
13 Incorrect 53 ms 68072 KB Output isn't correct
14 Incorrect 52 ms 68072 KB Output isn't correct
15 Incorrect 62 ms 68072 KB Output isn't correct
16 Incorrect 63 ms 68072 KB Output isn't correct
17 Incorrect 55 ms 68072 KB Output isn't correct
18 Incorrect 62 ms 69440 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 80344 KB Output is correct
2 Incorrect 96 ms 80344 KB Output isn't correct
3 Incorrect 286 ms 98576 KB Output isn't correct
4 Incorrect 108 ms 98576 KB Output isn't correct
5 Correct 183 ms 106876 KB Output is correct
6 Incorrect 961 ms 263804 KB Output isn't correct
7 Correct 69 ms 263804 KB Output is correct
8 Correct 72 ms 263804 KB Output is correct
9 Incorrect 48 ms 263804 KB Output isn't correct
10 Correct 48 ms 263804 KB Output is correct
11 Incorrect 66 ms 263804 KB Output isn't correct
12 Correct 48 ms 263804 KB Output is correct
13 Incorrect 93 ms 263804 KB Output isn't correct
14 Incorrect 80 ms 263804 KB Output isn't correct
15 Correct 76 ms 263804 KB Output is correct
16 Incorrect 72 ms 263804 KB Output isn't correct
17 Incorrect 148 ms 263804 KB Output isn't correct
18 Correct 137 ms 263804 KB Output is correct
19 Incorrect 118 ms 263804 KB Output isn't correct
20 Incorrect 119 ms 263804 KB Output isn't correct
21 Incorrect 221 ms 263804 KB Output isn't correct
22 Correct 182 ms 263804 KB Output is correct
23 Incorrect 221 ms 263804 KB Output isn't correct
24 Correct 201 ms 263804 KB Output is correct
25 Correct 334 ms 263804 KB Output is correct
26 Correct 1258 ms 780872 KB Output is correct
27 Incorrect 1221 ms 780872 KB Output isn't correct
28 Incorrect 963 ms 780872 KB Output isn't correct
29 Incorrect 984 ms 780872 KB Output isn't correct
30 Incorrect 977 ms 780872 KB Output isn't correct
31 Incorrect 621 ms 780872 KB Output isn't correct
32 Incorrect 689 ms 780872 KB Output isn't correct