#include <iostream>
#include <vector>
#define pb push_back
#define endl '\n'
using namespace std;
const int MAXN = 3e7+100;
vector<int> adj[MAXN];
char tp[MAXN];
int h, w, n;
string mat[4010];
int cnt;
bool used[MAXN];
void dfs(int v, int ld){
cout << v << endl;
used[v] = 1;
for(int u : adj[v]){
if(used[u]) continue;
if(tp[u] == tp[v] || tp[u] == '-' || tp[v] == '-') dfs(u, ld);
else if(tp[v] != '-'){
adj[u].pb(n+ld);
adj[n+ld].pb(u);
// cout << u << "<->" << n+ld << endl;
}
}
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
cin >> h >> w;
n = h*w;
for(int i=0;i<h; i++) cin >> mat[i];
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
int v, u, u_;
v = (i*w) + j;
u = (i+1)*w + j;
u_ = i*w + j + 1;
if(tp[v] == '.') continue;
if(i < (h-1) && tp[u] != '.'){
adj[v].pb(u);
adj[u].pb(v);
}
if(j < (w-1) && tp[u] != '.'){
adj[v].pb(u_);
adj[u_].pb(v);
}
tp[v] = mat[i][j];
}
}
for(int i=0; i<n; i++){
if(used[i] || tp[i] == '.') continue;
used[i] = 1;
tp[cnt + n] = '-';
// dfs(i, cnt);
cnt++;
}
cout << cnt << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
204 ms |
716228 KB |
Output isn't correct |
2 |
Incorrect |
147 ms |
708204 KB |
Output isn't correct |
3 |
Incorrect |
149 ms |
708272 KB |
Output isn't correct |
4 |
Incorrect |
167 ms |
713296 KB |
Output isn't correct |
5 |
Incorrect |
163 ms |
710972 KB |
Output isn't correct |
6 |
Incorrect |
154 ms |
708116 KB |
Output isn't correct |
7 |
Incorrect |
170 ms |
708208 KB |
Output isn't correct |
8 |
Incorrect |
151 ms |
708180 KB |
Output isn't correct |
9 |
Incorrect |
163 ms |
708324 KB |
Output isn't correct |
10 |
Incorrect |
155 ms |
710224 KB |
Output isn't correct |
11 |
Incorrect |
162 ms |
709316 KB |
Output isn't correct |
12 |
Incorrect |
156 ms |
710908 KB |
Output isn't correct |
13 |
Incorrect |
157 ms |
710740 KB |
Output isn't correct |
14 |
Incorrect |
162 ms |
710736 KB |
Output isn't correct |
15 |
Incorrect |
177 ms |
716516 KB |
Output isn't correct |
16 |
Incorrect |
175 ms |
716116 KB |
Output isn't correct |
17 |
Incorrect |
177 ms |
716088 KB |
Output isn't correct |
18 |
Incorrect |
167 ms |
713124 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
159 ms |
709792 KB |
Output isn't correct |
2 |
Incorrect |
305 ms |
760976 KB |
Output isn't correct |
3 |
Runtime error |
932 ms |
1048576 KB |
Execution killed with signal 9 |
4 |
Incorrect |
499 ms |
835944 KB |
Output isn't correct |
5 |
Incorrect |
958 ms |
1021024 KB |
Output isn't correct |
6 |
Runtime error |
931 ms |
1048576 KB |
Execution killed with signal 9 |
7 |
Incorrect |
154 ms |
709620 KB |
Output isn't correct |
8 |
Incorrect |
163 ms |
709628 KB |
Output isn't correct |
9 |
Incorrect |
162 ms |
710140 KB |
Output isn't correct |
10 |
Incorrect |
155 ms |
709240 KB |
Output isn't correct |
11 |
Incorrect |
157 ms |
709712 KB |
Output isn't correct |
12 |
Incorrect |
151 ms |
708944 KB |
Output isn't correct |
13 |
Incorrect |
295 ms |
760772 KB |
Output isn't correct |
14 |
Incorrect |
243 ms |
738136 KB |
Output isn't correct |
15 |
Incorrect |
238 ms |
741464 KB |
Output isn't correct |
16 |
Incorrect |
203 ms |
729544 KB |
Output isn't correct |
17 |
Incorrect |
528 ms |
849324 KB |
Output isn't correct |
18 |
Incorrect |
522 ms |
844948 KB |
Output isn't correct |
19 |
Incorrect |
478 ms |
835704 KB |
Output isn't correct |
20 |
Incorrect |
482 ms |
826996 KB |
Output isn't correct |
21 |
Incorrect |
968 ms |
1029168 KB |
Output isn't correct |
22 |
Incorrect |
967 ms |
1020868 KB |
Output isn't correct |
23 |
Incorrect |
836 ms |
977020 KB |
Output isn't correct |
24 |
Incorrect |
946 ms |
1023784 KB |
Output isn't correct |
25 |
Runtime error |
937 ms |
1048576 KB |
Execution killed with signal 9 |
26 |
Runtime error |
952 ms |
1048576 KB |
Execution killed with signal 9 |
27 |
Runtime error |
918 ms |
1048576 KB |
Execution killed with signal 9 |
28 |
Runtime error |
921 ms |
1048576 KB |
Execution killed with signal 9 |
29 |
Runtime error |
923 ms |
1048576 KB |
Execution killed with signal 9 |
30 |
Runtime error |
929 ms |
1048576 KB |
Execution killed with signal 9 |
31 |
Runtime error |
916 ms |
1048576 KB |
Execution killed with signal 9 |
32 |
Runtime error |
924 ms |
1048576 KB |
Execution killed with signal 9 |