-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday01.cpp
77 lines (67 loc) · 1.42 KB
/
day01.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
66
67
68
69
70
71
72
73
74
75
76
77
/*
lengli_QAQ
Hope there are no bugs!!!
*/
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
//--------------------------------
template<typename T> void printvt(vector<T> &a){
for(auto x:a) cout<<x<<" ";cout<<endl;
};
template<typename T> void printay(T a[],int l,int r){
for(int i=l;i<=r;i++) cout<<a[i]<<" ";cout<<endl;
};
//--------------------------------
typedef pair<int,int> PII;
typedef long long LL;
const int N=100010;
vector<string> g;
map<string,int> q={
{"one",1}, {"two",2}, {"three",3},{"four",4},{"five",5},{"six",6},{"seven",7},{"eight",8},{"nine",9}
};
int get(string s){
int l=-1,r=-1;
for(int i=0;i<s.size() and l==-1;i++){
if(s[i]>='0' and s[i]<='9') l=s[i]-'0';
else{
for(auto [x,v]:q){
int len=x.size();
if(i+len>=s.size()) continue;
string t=s.substr(i,len);
if(t==x) l=v;
}
}
}
for(int i=s.size()-1;i>=0 and r==-1;i--){
if(s[i]>='0' and s[i]<='9') r=s[i]-'0';
else{
for(auto [x,v]:q){
int len=x.size();
if(i-len+1<0) continue;
string t=s.substr(i-len+1,len);
if(t==x) r=v;
}
}
}
return l*10+r;
}
void solve(){
string s;
while(cin>>s) g.pb(s);
int res=0;
for(int i=0;i<g.size();i++) {
res+=get(g[i]);
}
cout<<res;
}
signed main(){
fastio;
int T;
T=1;
while(T--) solve();
return 0;
}