1 solutions
-
0
#include <iostream> using namespace std; const int x= 2e3 + 5; int n,T; string s,t; bool check(char a,char b){ if (a == 'A' && b == 'T') return 1; if (a == 'T' && b == 'A') return 1; if (a == 'C' && b == 'G') return 1; if (a == 'G' && b == 'C') return 1; return 0; } long long calc(string s){ string t = s; for (int i=0;i<s.size();i++) t[i] = s[n-1-i]; long long ans = 0; for (int i=0;i<s.size();i++){ if (s[i]!='A'&&s[i]!='T'&&s[i]!='C'&&s[i]!='G') return 0; if (check(s[i],t[i])) ans += i+1; } return ans; } int main(){ cin >> T; while (T--){ cin >> n; cin >> s; printf("%lld\n",calc(s)); } return 0; }
- 1
Information
- ID
- 9136
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 2
- Tags
- # Submissions
- 98
- Accepted
- 24
- Uploaded By