-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2125.cpp
More file actions
39 lines (26 loc) · 734 Bytes
/
2125.cpp
File metadata and controls
39 lines (26 loc) · 734 Bytes
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
#include<iostream>
#include<vector>
#include<algorithm>
int numberOfBeams(std::vector<std::string>& bank) {
int beams = 0;
int res = 0;
std::vector<int> temp;
for(int i = 0; i < bank.size(); ++i) {
int count = std::count(bank[i].begin(), bank[i].end(), '1');
if(count != 0) {
temp.push_back(count);
}
}
if(!temp.empty()) {
for (int i = 0; i < temp.size() - 1; ++i) {
beams += temp[i] * temp[i + 1];
}
}
return beams;
}
int main() {
// std::vector<std::string> bank = { "011001","000000","010100","001000" };
std::vector<std::string> bank = { "0" };
std::cout << "\n" << numberOfBeams(bank);
std::cin.get();
}