Submission #1544091
Source Code Expand
#include <bits/stdc++.h> using namespace std; template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; } template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); } template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); } #define len(_x) (sizeof((_x)) / sizeof(_x)[0]) #define ll long long #define itr(_c) for(auto i=_c.begin();i!=_c.end();i++) #define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++) #define f1(_x)for (int i = 0; i < _x; ++i) #define fr(_x)for (int i = _x; i >0; i--) #define f2(_x,_y)for (int i = _x; i < _y; ++i) #define fileIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); typedef pair<int, int>pii; typedef pair<long, long>pll; typedef pair<string, int>psi; typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<long long>vll; typedef vector<pair<int,int> > vii; typedef set<int> si; typedef set<string> ss; typedef set<bool> sb; typedef set<long long>sll; typedef set<pair<int, int> > sii; typedef list<int> li; typedef list<string> ls; typedef list<bool> lb; typedef list<long long>lll; typedef list<pair<int, int> > lii; typedef map<string, int> msi; void fastIO(){ ios_base::sync_with_stdio(false); cin.tie(0); } ll sss(ll a) { return a*(a - 1) / 2; } int arr[26]; int main() { string s; cin >> s; ll l = s.size(), sum=0; for (char ch='a';ch<='z';ch++) { arr[ch - 97]=count(s.begin(), s.end(),ch); } for(auto e: arr) { sum += sss(e); } std::cout << sss(l)-sum+1; }
Submission Info
Submission Time | |
---|---|
Task | B - Reverse and Compare |
User | coderWithStyle |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 2096 Byte |
Status | AC |
Exec Time | 11 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 | 11 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 | 11 ms | 640 KB |
subtask_1_09.txt | AC | 11 ms | 640 KB |
subtask_1_10.txt | AC | 11 ms | 640 KB |
subtask_1_11.txt | AC | 11 ms | 640 KB |
subtask_1_12.txt | AC | 11 ms | 640 KB |
subtask_1_13.txt | AC | 11 ms | 640 KB |
subtask_1_14.txt | AC | 11 ms | 640 KB |
subtask_1_15.txt | AC | 11 ms | 640 KB |
subtask_1_16.txt | AC | 11 ms | 640 KB |
subtask_1_17.txt | AC | 11 ms | 640 KB |