結果
問題 | No.2419 MMA文字列2 |
ユーザー |
![]() |
提出日時 | 2023-08-12 14:22:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 1,992 bytes |
コンパイル時間 | 4,524 ms |
コンパイル使用メモリ | 260,648 KB |
最終ジャッジ日時 | 2025-02-16 04:44:14 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#if !__INCLUDE_LEVEL__#include __FILE__void solve(){string S; cin>>S;ull cnt=0,c=0;map<char,ll> m;map<char,ll> s;rep(i,sz(S)){m[S[i]]++;if(m[S[i]]>=2){s[S[i]]+=m[S[i]]-1;c+=m[S[i]]-1;cnt+=c-s[S[i]];}else cnt+=c;}debug(m,s);cout<<cnt<<endl;}#else#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;#pragma GCC target("avx2")#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")#define FOR(i,l,r) for(int i=(l);i<(r);++i)#define rep(i,n) FOR(i,0,n)using ll = long long;using ull = unsigned long long;using pii = pair<int, int>;using pll = pair<long long,long long>;using vi = vector<int>;using vs = vector<string>;using vll = vector<long long>;#define pf push_front#define pb push_back#define mp make_pair#define fi first#define se second#define sz(x) ((int)x.size())#define pqueue priority_queue#define all(x) (x).begin(), (x).end()#define rall(x) (x).rbegin(), (x).rend()int dx[4] = {1, 0, -1, 0};int dy[4] = {0, 1, 0, -1};#define INF (1<<30)-1#define INFLL (1LL<<60)-1#define pcnt __builtin_popcount#define bit(n) (1LL<<(n))#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end());template<typename T> void out(T vec){for(int c:vec)cout<<c<<' ';}void yn(bool flag){if(flag)cout<<"Yes"<<'\n'; else cout<<"No"<<'\n';}template <typename T>bool chmax(T &a,const T& b){if(a<b){a=b;return true;}return false;}template <typename T>bool chmin(T &a,const T& b){if(a>b){a=b;return true;}return false;}void solve();// const int mod = ;// using mint = modint998244353;// using mint = modint1000000007;#ifdef LOCAL# include <debug_print.hpp># define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)#else# define debug(...) (static_cast<void>(0))#endifint main(){cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(10);solve();}#endif