Submission #60366683


Source Code Expand

#include<bits/stdc++.h>
#include"atcoder/all"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll inf=1ll<<61;
typedef modint1000000007 mi;

int main(){
	ll n;cin>>n;
	string s;cin>>s;
	ll ans=n*(n+1)/2;
	
	ll cnt=0;
	char now=s[0];

	rep(i,n){
		if(s[i]==now)cnt++;
		else{
			ans-=cnt*(cnt+1)/2;
			now=s[i];
			cnt=1;
		}
	}
	ans-=cnt*(cnt+1)/2;
	cout<<ans<<endl;
}

Submission Info

Submission Time
Task 084 - There are two types of characters(★3)
User Rho17
Language C++ 20 (gcc 12.2)
Score 3
Code Size 568 Byte
Status AC
Exec Time 17 ms
Memory 5300 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 3 / 3
Status
AC × 4
AC × 37
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 09_hand_o.txt, 09_hand_oo.txt, 09_hand_ox.txt, 09_hand_x.txt, 09_hand_xo.txt, 09_hand_xx.txt, 10_small_random_03.txt, 10_small_random_04.txt, 10_small_random_05.txt, 10_small_random_06.txt, 10_small_random_07.txt, 10_small_random_08.txt, 10_small_random_09.txt, 50_large_random_01.txt, 50_large_random_02.txt, 50_large_random_03.txt, 50_large_random_04.txt, 60_alternate_01.txt, 60_alternate_02.txt, 70_o1000000_01.txt, 70_o500000_x500000_01.txt, 70_o999998_x2_01.txt, 70_o999999_x1_01.txt, 70_x1000000_01.txt, 70_x500000_o500000_01.txt, 70_x999998_o2_01.txt, 70_x999999_o1_01.txt, 80_little_o_01.txt, 80_little_o_02.txt, 80_little_o_03.txt, 80_little_x_01.txt, 80_little_x_02.txt, 80_little_x_03.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 3 ms 3492 KiB
00_sample_02.txt AC 1 ms 3520 KiB
00_sample_03.txt AC 1 ms 3524 KiB
00_sample_04.txt AC 1 ms 3572 KiB
09_hand_o.txt AC 1 ms 3392 KiB
09_hand_oo.txt AC 1 ms 3632 KiB
09_hand_ox.txt AC 1 ms 3636 KiB
09_hand_x.txt AC 1 ms 3636 KiB
09_hand_xo.txt AC 1 ms 3476 KiB
09_hand_xx.txt AC 1 ms 3580 KiB
10_small_random_03.txt AC 1 ms 3508 KiB
10_small_random_04.txt AC 1 ms 3492 KiB
10_small_random_05.txt AC 1 ms 3524 KiB
10_small_random_06.txt AC 1 ms 3576 KiB
10_small_random_07.txt AC 1 ms 3508 KiB
10_small_random_08.txt AC 1 ms 3492 KiB
10_small_random_09.txt AC 1 ms 3516 KiB
50_large_random_01.txt AC 17 ms 5276 KiB
50_large_random_02.txt AC 17 ms 5240 KiB
50_large_random_03.txt AC 17 ms 5200 KiB
50_large_random_04.txt AC 17 ms 5300 KiB
60_alternate_01.txt AC 14 ms 5152 KiB
60_alternate_02.txt AC 14 ms 5220 KiB
70_o1000000_01.txt AC 13 ms 5276 KiB
70_o500000_x500000_01.txt AC 13 ms 5220 KiB
70_o999998_x2_01.txt AC 13 ms 5224 KiB
70_o999999_x1_01.txt AC 14 ms 5216 KiB
70_x1000000_01.txt AC 14 ms 5212 KiB
70_x500000_o500000_01.txt AC 14 ms 5208 KiB
70_x999998_o2_01.txt AC 14 ms 5200 KiB
70_x999999_o1_01.txt AC 14 ms 5236 KiB
80_little_o_01.txt AC 14 ms 5300 KiB
80_little_o_02.txt AC 13 ms 5220 KiB
80_little_o_03.txt AC 14 ms 5272 KiB
80_little_x_01.txt AC 13 ms 5268 KiB
80_little_x_02.txt AC 14 ms 5112 KiB
80_little_x_03.txt AC 14 ms 5224 KiB