#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cassert>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
#define f first
#define s second
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};
void setIO(string nome) {
ios_base::sync_with_stdio(0); cin.tie(0);
freopen ((nome + ".in").c_str(), "r", stdin);
freopen ((nome + ".out").c_str(), "w", stdout);
}
int reverse (int n) {
int res = 0;
while (n) {
res = res * 10 + (n % 10);
n /= 10;
}
return res;
}
bool valid (int n) {
return n == reverse (n);
}
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
i64 tot = 0;
F0R (i, n) {
int foo;
cin >> foo;
if (valid(foo)) tot += foo;
}
cout << tot << '\n';
return 0;
}
Compilation message
palindromes.cpp: In function 'void setIO(std::__cxx11::string)':
palindromes.cpp:38:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen ((nome + ".in").c_str(), "r", stdin);
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
palindromes.cpp:39:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen ((nome + ".out").c_str(), "w", stdout);
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
504 KB |
Output is correct |
3 |
Correct |
85 ms |
5240 KB |
Output is correct |
4 |
Correct |
131 ms |
7544 KB |
Output is correct |
5 |
Correct |
168 ms |
9976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
42 ms |
1784 KB |
Output is correct |
4 |
Correct |
71 ms |
3192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
42 ms |
1784 KB |
Output is correct |
4 |
Correct |
71 ms |
3192 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
71 ms |
3320 KB |
Output is correct |
8 |
Correct |
90 ms |
4240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
504 KB |
Output is correct |
3 |
Correct |
85 ms |
5240 KB |
Output is correct |
4 |
Correct |
131 ms |
7544 KB |
Output is correct |
5 |
Correct |
168 ms |
9976 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
42 ms |
1784 KB |
Output is correct |
9 |
Correct |
71 ms |
3192 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
71 ms |
3320 KB |
Output is correct |
13 |
Correct |
90 ms |
4240 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
11 ms |
636 KB |
Output is correct |
16 |
Correct |
79 ms |
4216 KB |
Output is correct |
17 |
Correct |
155 ms |
9080 KB |
Output is correct |
18 |
Correct |
173 ms |
9976 KB |
Output is correct |
19 |
Correct |
168 ms |
9976 KB |
Output is correct |
20 |
Correct |
165 ms |
9976 KB |
Output is correct |