-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay12.cpp
More file actions
83 lines (68 loc) · 1.76 KB
/
Day12.cpp
File metadata and controls
83 lines (68 loc) · 1.76 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <bits/stdc++.h>
#define int long long
#define allr(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define ld long double
#define INF (int)(1e18)
#define MOD 1000000007
using namespace std;
void Final() {
string s;
vector<int> cnt(10, 0);
vector<pair<vector<int>, pair<int,int> > > set;
int c = 0, ind = -1;
while (getline(cin, s) && s != "*") {
stringstream ss(s);
string t, x;
ss >> t;
for (int i = 0; i < t.size(); i++) {
if (t[i] == '#')c++;
}
if (t[0] >= '0' && t[0] <= '9') {
if (ind != -1 && ind < 10) {
cnt[ind] = c;
//cout << ind << " " << c << "\n";
}
ind++;
c = 0;
}
int f = t.find("x");
if (f != -1) {
vector<int> a;
int n = stoll(t.substr(0, f));
int f2 = t.find(":");
int m = stoll(t.substr(f + 1, f2));;
while (ss >> t) {
a.push_back(stoll(t));
}
//cout << n << " " << m << endl;
set.push_back({a, {n, m}});
}
}
int ans = 0;
for (int i = 0; i < set.size(); i++) {
vector<int> a = set[i].first;
auto [n,m] = set[i].second;
int cnt_ = 0, sum = 0;
for (int j = 0; j < a.size(); j++) {
cnt_ += (a[j] * cnt[j]);
}
cout << endl;
if (cnt_ < n * m) {
ans++;
}
}
cout << ans << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("promote.in","r",stdin);
// freopen("promote.out","w",stdout);
int tests = 1;
// cin >> tests;
while (tests--) {
Final();
}
}