# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
725472 |
2023-04-17T13:52:42 Z |
kerem |
Zoo (COCI19_zoo) |
C++14 |
|
2000 ms |
10084 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fir first
#define sec second
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n,m,vis[1005][1005],sum,t=0;
char a[1005][1005];
void bfs(char c,int x,int y){
t=0;
queue<pair<int,int>> q;
q.push({x,y});
while(!q.empty()){
x=q.front().fir;
y=q.front().sec;
q.pop();
if(a[x][y]!=c) continue;
if(c=='B') a[x][y]='T';
else a[x][y]='B';
t++;
if(a[x+1][y]==c)
q.push({x+1,y});
if(a[x-1][y]==c)
q.push({x-1,y});
if(a[x][y+1]==c)
q.push({x,y+1});
if(a[x][y-1]==c)
q.push({x,y-1});
}
return;
}
int32_t main(){
int ans=0;
memset(vis,0,sizeof(vis));
cin >> n >> m;
sum=n*m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin >> a[i][j];
if(a[i][j]=='*')
sum--;
}
}
while(t!=sum){
ans++;
bfs(a[1][1],1,1);
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8148 KB |
Output is correct |
2 |
Correct |
4 ms |
8220 KB |
Output is correct |
3 |
Correct |
4 ms |
8148 KB |
Output is correct |
4 |
Correct |
4 ms |
8148 KB |
Output is correct |
5 |
Correct |
5 ms |
8276 KB |
Output is correct |
6 |
Correct |
5 ms |
8276 KB |
Output is correct |
7 |
Correct |
4 ms |
8216 KB |
Output is correct |
8 |
Correct |
8 ms |
8300 KB |
Output is correct |
9 |
Correct |
8 ms |
8284 KB |
Output is correct |
10 |
Correct |
9 ms |
8276 KB |
Output is correct |
11 |
Correct |
9 ms |
8276 KB |
Output is correct |
12 |
Correct |
10 ms |
8224 KB |
Output is correct |
13 |
Correct |
8 ms |
8220 KB |
Output is correct |
14 |
Correct |
7 ms |
8224 KB |
Output is correct |
15 |
Correct |
8 ms |
8276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8148 KB |
Output is correct |
2 |
Correct |
4 ms |
8220 KB |
Output is correct |
3 |
Correct |
4 ms |
8148 KB |
Output is correct |
4 |
Correct |
4 ms |
8148 KB |
Output is correct |
5 |
Correct |
5 ms |
8276 KB |
Output is correct |
6 |
Correct |
5 ms |
8276 KB |
Output is correct |
7 |
Correct |
4 ms |
8216 KB |
Output is correct |
8 |
Correct |
8 ms |
8300 KB |
Output is correct |
9 |
Correct |
8 ms |
8284 KB |
Output is correct |
10 |
Correct |
9 ms |
8276 KB |
Output is correct |
11 |
Correct |
9 ms |
8276 KB |
Output is correct |
12 |
Correct |
10 ms |
8224 KB |
Output is correct |
13 |
Correct |
8 ms |
8220 KB |
Output is correct |
14 |
Correct |
7 ms |
8224 KB |
Output is correct |
15 |
Correct |
8 ms |
8276 KB |
Output is correct |
16 |
Correct |
75 ms |
10084 KB |
Output is correct |
17 |
Correct |
77 ms |
10060 KB |
Output is correct |
18 |
Correct |
66 ms |
10032 KB |
Output is correct |
19 |
Correct |
76 ms |
10064 KB |
Output is correct |
20 |
Correct |
68 ms |
10028 KB |
Output is correct |
21 |
Execution timed out |
2095 ms |
10036 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |