#include <cstdio>
#include <cstdint>
#include <queue>
#include "palindromy.h"
#include "message.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
typedef long long LL;
int main() {
if (MyNodeId()) return 0;
int n = GetLength();
LL r = 0;
queue<int32_t> q;
REP(i,n) {
q.push(i << 1);
int x = q.size();
REP(k,x) {
int m = q.front();
q.pop();
int j = m - i;
char a = GetLetter(i);
if (j >= 0 && a == GetLetter(j)) {
++r;
q.push(m);
}
}
q.push((i << 1) + 1);
}
printf("%lld\n", r);
}
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 | #include <cstdio> #include <cstdint> #include <queue> #include "palindromy.h" #include "message.h" using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) typedef long long LL; int main() { if (MyNodeId()) return 0; int n = GetLength(); LL r = 0; queue<int32_t> q; REP(i,n) { q.push(i << 1); int x = q.size(); REP(k,x) { int m = q.front(); q.pop(); int j = m - i; char a = GetLetter(i); if (j >= 0 && a == GetLetter(j)) { ++r; q.push(m); } } q.push((i << 1) + 1); } printf("%lld\n", r); } |
English