Submission #1540870
Source Code Expand
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
//container util
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
VI alp[26];
int main() {
string a;
cin >> a;
ll ans = 1;
int n = a.size();
REP(i,n){
alp[a[i]-'a'].push_back(i);
}
REP(i, 26)REP(k, (int)alp[i].size())REP(j,26)if(i!=j){
int p = alp[i][k];
ans += alp[j].end() - lower_bound(ALL(alp[j]),p);
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Reverse and Compare |
User |
luma |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
1446 Byte |
Status |
AC |
Exec Time |
221 ms |
Memory |
1908 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
All |
sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
1 ms |
256 KB |
sample_02.txt |
AC |
1 ms |
256 KB |
sample_03.txt |
AC |
1 ms |
256 KB |
subtask_1_01.txt |
AC |
1 ms |
256 KB |
subtask_1_02.txt |
AC |
19 ms |
1532 KB |
subtask_1_03.txt |
AC |
1 ms |
256 KB |
subtask_1_04.txt |
AC |
1 ms |
256 KB |
subtask_1_05.txt |
AC |
1 ms |
256 KB |
subtask_1_06.txt |
AC |
2 ms |
256 KB |
subtask_1_07.txt |
AC |
16 ms |
384 KB |
subtask_1_08.txt |
AC |
221 ms |
1412 KB |
subtask_1_09.txt |
AC |
27 ms |
1384 KB |
subtask_1_10.txt |
AC |
35 ms |
1600 KB |
subtask_1_11.txt |
AC |
194 ms |
1540 KB |
subtask_1_12.txt |
AC |
27 ms |
1532 KB |
subtask_1_13.txt |
AC |
33 ms |
1908 KB |
subtask_1_14.txt |
AC |
19 ms |
1532 KB |
subtask_1_15.txt |
AC |
24 ms |
1660 KB |
subtask_1_16.txt |
AC |
27 ms |
1532 KB |
subtask_1_17.txt |
AC |
104 ms |
1284 KB |