Submission #5746871
Source Code Expand
#include <vector> #include <iostream> #include <cmath> #include <map> #include <unordered_map> #include <algorithm> #include <fstream> #include <unistd.h> #include <string> #include <numeric> #include <queue> #include <deque> #include <sstream> #include <iomanip> #include <set> #include <stack> #include <cassert> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef vector<vvb> vvvb; typedef vector<vvvb> vvvvb; typedef vector<string> vs; typedef vector<vector<string>> vvs; typedef vector<char> vc; typedef vector<vector<char>> vvc; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<vvd> vvvd; typedef pair<int, int> P; typedef pair<ll, ll> PL; typedef vector<P> vp; typedef vector<PL> vpl; typedef vector<vector<P>> vvp; typedef vector<vector<PL>> vvpl; const int INF = 1001001001; const ll LINF = 1e17; const double pi = 3.1415926535897932; const string endstr = "\n"; #define FOR(i, a, b) for(ll i = (a); i < b; i++) #define RFOR(i, a, b) for(ll i = (a); i > b; i--) #define REP(i, n) for(ll i = 0; i < n; i++) #define RREP(i, n) for(ll i = n-1; i > -1; i--) #define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++) #define ff first #define ss second #define pb push_back #define epb emplace_back template <typename T> T gcd(T a, T b) { return (a == 0) ? b : gcd(b%a, a); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;}; bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;}; bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;}; bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;}; template <typename T> vector<T> uniquen(vector<T> vec){ vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; } int main(){ string A; cin >> A; ll N = A.size(); vl cnt(26,0); REP(i, N){ cnt[A[i]-'a']++; } ll ans = N*(N-1)/2+1; REP(i, 26){ ll c = cnt[i]; ans -= c*(c-1)/2; } cout << ans << endstr; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Reverse and Compare |
User | k_k_hiroki |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 2367 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 640 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 | 8 ms | 640 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 | 1 ms | 256 KB |
subtask_1_07.txt | AC | 2 ms | 256 KB |
subtask_1_08.txt | AC | 8 ms | 640 KB |
subtask_1_09.txt | AC | 8 ms | 640 KB |
subtask_1_10.txt | AC | 8 ms | 640 KB |
subtask_1_11.txt | AC | 7 ms | 640 KB |
subtask_1_12.txt | AC | 8 ms | 640 KB |
subtask_1_13.txt | AC | 8 ms | 640 KB |
subtask_1_14.txt | AC | 8 ms | 640 KB |
subtask_1_15.txt | AC | 8 ms | 640 KB |
subtask_1_16.txt | AC | 8 ms | 640 KB |
subtask_1_17.txt | AC | 8 ms | 640 KB |