Submission #58695343


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

#define inf 1001000009
#define infmx 1e18
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define MP make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define all(x) x.begin(),x.end()
///debug
#define wh(x)   cerr<<#x<<" is "<<x<<endl;
#define error(args...){string _s=#args;replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);err(_it,args);}
void err(istream_iterator<string>it){cout<<endl;}
template<class H,class... T>void err(istream_iterator<string>it,H a,T... t){cout<<*it<<" = "<<a<<" | ";err(++it,t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class T>auto&operator<<(ostream& os,vector<T>_v){bool a=1;for(auto x:_v){os<<(a?"":" ")<<x;a=0;}return os;}
///
inline void YN(bool f){cout<<(f?"YES":"NO")<<endl;}
inline void Yn(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void yn(bool f){cout<<(f?"yes":"no")<<endl;}


typedef pair<int,int>pi;
typedef pair<long long,long long>pll;
typedef pair<pi,int>ppi;
typedef pair<int,pi>pip;
typedef vector<int>vi;
typedef vector<pi>vpi;
const int mod=1e9+7;
ll power(ll a,ll p){ll r=1,y=a%mod;while(p){if(p&1)r=(1LL*r*y)%mod;p>>=1;y=(1LL*y*y)%mod;}return r;}

const int N=2100000;
int ara[N];


int main()
{
    IOS;
 	string s;
 	cin>>s;
 	vector<int>cnt1(26, 0), cnt2(26, 0);
 	for(auto x:s)cnt2[x-'A']++;
 	ll ans = 0;
 	for(auto x:s){
 		cnt2[x-'A']--;
 		for(int i = 0; i < 26; i++){
 			ans += 1ll * cnt1[i] * cnt2[i];
 		}
 		cnt1[x-'A']++;
 	}   
 	cout<<ans<<endl;
}

Submission Info

Submission Time
Task D - ABA
User purple_ghost
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1706 Byte
Status AC
Exec Time 5 ms
Memory 3668 KiB

Compile Error

Main.cpp: In function ‘void err(std::istream_iterator<std::__cxx11::basic_string<char> >)’:
Main.cpp:16:34: warning: unused parameter ‘it’ [-Wunused-parameter]
   16 | void err(istream_iterator<string>it){cout<<endl;}
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 34
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt
Case Name Status Exec Time Memory
sample00.txt AC 1 ms 3320 KiB
sample01.txt AC 1 ms 3472 KiB
sample02.txt AC 1 ms 3412 KiB
testcase00.txt AC 1 ms 3388 KiB
testcase01.txt AC 1 ms 3344 KiB
testcase02.txt AC 1 ms 3484 KiB
testcase03.txt AC 2 ms 3556 KiB
testcase04.txt AC 5 ms 3576 KiB
testcase05.txt AC 2 ms 3632 KiB
testcase06.txt AC 5 ms 3596 KiB
testcase07.txt AC 1 ms 3504 KiB
testcase08.txt AC 5 ms 3596 KiB
testcase09.txt AC 1 ms 3508 KiB
testcase10.txt AC 5 ms 3668 KiB
testcase11.txt AC 1 ms 3380 KiB
testcase12.txt AC 5 ms 3612 KiB
testcase13.txt AC 1 ms 3524 KiB
testcase14.txt AC 5 ms 3580 KiB
testcase15.txt AC 4 ms 3572 KiB
testcase16.txt AC 5 ms 3508 KiB
testcase17.txt AC 1 ms 3468 KiB
testcase18.txt AC 5 ms 3668 KiB
testcase19.txt AC 3 ms 3596 KiB
testcase20.txt AC 4 ms 3600 KiB
testcase21.txt AC 1 ms 3588 KiB
testcase22.txt AC 5 ms 3592 KiB
testcase23.txt AC 3 ms 3576 KiB
testcase24.txt AC 4 ms 3448 KiB
testcase25.txt AC 2 ms 3600 KiB
testcase26.txt AC 4 ms 3548 KiB
testcase27.txt AC 3 ms 3548 KiB
testcase28.txt AC 4 ms 3592 KiB
testcase29.txt AC 2 ms 3596 KiB
testcase30.txt AC 5 ms 3512 KiB