-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstar1.cpp
65 lines (58 loc) · 1.5 KB
/
star1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <bits/stdc++.h>
struct Tree{
int v;
int visible;
};
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
std::string inp;
std::vector<std::vector<Tree>> tab;
while(std::cin>>inp){
std::vector<Tree> temp;
for(char &c: inp){
temp.push_back({(int)c-48,0});
}
tab.push_back(temp);
}
int max{-1},sum{0};
for(auto &row : tab){
max = -1;
for(auto &tree : row){
tree.visible += tree.v > max;
max = std::max(max,tree.v);
}
max = -1;
for(int i = row.size()-1; i>=0;i--){
Tree& tree = row[i];
tree.visible += tree.v > max;
max = std::max(max,tree.v);
}
}
for(int i = 0; i<tab[0].size() ;i++){
max = -1;
for(int j = 0;j<tab.size();j++){
Tree& tree = tab[j][i];
tree.visible += tree.v > max;
max = std::max(max,tree.v);
}
max = -1;
for(int j = tab.size()-1;j>=0;j--){
Tree& tree = tab[j][i];
tree.visible += tree.v > max;
max = std::max(max,tree.v);
sum+=(tree.visible ==0);
}
}
std::cout<<tab.size()*tab[0].size() - sum<<"\n";
std::cout<<sum;
// for(auto &row : tab){
// for(auto &tree : row){
// std::cout<<tree.visible;
// }
// std::cout<<"\n";
// }
std::cout.flush();
return 0;
}