| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 448707 | Antekb | Zoo (COCI19_zoo) | C++14 | 103 ms | 38676 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define st first
#define nd second
using namespace std;
const int N=1005;
int tab[N][N], dist[N][N];
vector<pair<int, int> > co[N*N];
vector<pair<int, int> > V={{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main(){
int n, m;
cin>>n>>m;
for(int i=0; i<n; i++){
string s;
cin>>s;
for(int j=0; j<m; j++){
if(s[j]=='T')tab[i][j]=1;
if(s[j]=='B')tab[i][j]=2;
}
}
dist[0][0]=1;
co[1].push_back({0, 0});
int ans=0;
for(int i=1; i<=n*m; i++){
for(int j=0; j<co[i].size(); j++){
//cout<<v.st<<" "<<v.nd<<"\n";
ans=max(ans, i);
int x=co[i][j].st, y=co[i][j].nd;
for(pair<int, int> d:V){
if(x+d.st>=0 && y+d.nd>=0 && tab[x+d.st][y+d.nd]){
if(dist[x+d.st][y+d.nd]==0){
//cout<<"a";
if(tab[x+d.st][y+d.nd]!=tab[x][y]){
dist[x+d.st][y+d.nd]=dist[x][y]+1;
co[i+1].push_back({x+d.st, y+d.nd});
}
else{
dist[x+d.st][y+d.nd]=dist[x][y];
co[i].push_back({x+d.st, y+d.nd});
}
}
}
}
}
}
cout<<ans;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
