Submission #448707

# Submission time Handle Problem Language Result Execution time Memory
448707 2021-07-31T20:12:40 Z Antekb Zoo (COCI19_zoo) C++14
110 / 110
103 ms 38676 KB
#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

zoo.cpp: In function 'int main()':
zoo.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int j=0; j<co[i].size(); j++){
      |                ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23988 KB Output is correct
2 Correct 13 ms 24140 KB Output is correct
3 Correct 15 ms 24140 KB Output is correct
4 Correct 14 ms 24388 KB Output is correct
5 Correct 14 ms 24860 KB Output is correct
6 Correct 14 ms 24780 KB Output is correct
7 Correct 15 ms 24908 KB Output is correct
8 Correct 14 ms 24780 KB Output is correct
9 Correct 14 ms 24780 KB Output is correct
10 Correct 14 ms 24816 KB Output is correct
11 Correct 15 ms 24780 KB Output is correct
12 Correct 15 ms 24856 KB Output is correct
13 Correct 15 ms 24652 KB Output is correct
14 Correct 14 ms 24792 KB Output is correct
15 Correct 14 ms 24664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23988 KB Output is correct
2 Correct 13 ms 24140 KB Output is correct
3 Correct 15 ms 24140 KB Output is correct
4 Correct 14 ms 24388 KB Output is correct
5 Correct 14 ms 24860 KB Output is correct
6 Correct 14 ms 24780 KB Output is correct
7 Correct 15 ms 24908 KB Output is correct
8 Correct 14 ms 24780 KB Output is correct
9 Correct 14 ms 24780 KB Output is correct
10 Correct 14 ms 24816 KB Output is correct
11 Correct 15 ms 24780 KB Output is correct
12 Correct 15 ms 24856 KB Output is correct
13 Correct 15 ms 24652 KB Output is correct
14 Correct 14 ms 24792 KB Output is correct
15 Correct 14 ms 24664 KB Output is correct
16 Correct 48 ms 33480 KB Output is correct
17 Correct 47 ms 33488 KB Output is correct
18 Correct 49 ms 33600 KB Output is correct
19 Correct 50 ms 33760 KB Output is correct
20 Correct 48 ms 33596 KB Output is correct
21 Correct 88 ms 38028 KB Output is correct
22 Correct 90 ms 37896 KB Output is correct
23 Correct 101 ms 38008 KB Output is correct
24 Correct 92 ms 38568 KB Output is correct
25 Correct 91 ms 38312 KB Output is correct
26 Correct 88 ms 38084 KB Output is correct
27 Correct 85 ms 38000 KB Output is correct
28 Correct 96 ms 38104 KB Output is correct
29 Correct 103 ms 38676 KB Output is correct
30 Correct 90 ms 38296 KB Output is correct