Submission #923441

#TimeUsernameProblemLanguageResultExecution timeMemory
923441NValchanovPalindromes (info1cup18_palindromes)C++17
100 / 100
118 ms41412 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; const ll MAXN=1e6+10; const ll MAXA=1e9+10; ll n; string a[MAXN]; ll string_to_int(string s) { ll res=0; ll sz=s.size(); for(ll i=sz-1;i>=0;i--) { res*=10; res+=(s[i]-'0'); } return res; } bool isPalindrome(string s) { string revs=s; reverse(revs.begin(), revs.end()); return s == revs; } void read() { cin>>n; for(ll i=1;i<=n;i++) { cin>>a[i]; } } void solve() { ll ans=0; for(ll i=1;i<=n;i++) { string s=a[i]; if(isPalindrome(s)) { ll cur=string_to_int(s); ans+=cur; } } cout<<ans<<endl; } int main() { #ifdef ONLINE_JUDGE freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); read(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...