比赛 20230806测试 评测结果 RRRRRRRRRR
题目名称 叉叉 最终得分 0
用户昵称 wow草原 运行时间 0.005 s
代码语言 C++ 内存使用 13.37 MiB
提交时间 2023-08-06 10:13:38
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int a[1000010],c[1010],top=1,ans;
string s;
struct abc{
    int x, y;
};
bool cmp(abc a,abc b){
    return a.x<b.x;
}
abc nm[500005];
int main(){
//    freopen("xxxx.in","r",stdin);
//    freopen("xxxx.in","w",stdout);
    cin>>s;
    int n=s.size();
    for(int i=0;i<=n-1;i++){
        if(c[s[i]]!=0){
            nm[top].x=c[s[i]];
            nm[top++].y=i+1;
            c[s[i]]=0;
        }
        else{
            c[s[i]]=i+1;
        }
    }
    sort(nm+1,nm+top,cmp);
    for(int i=1;i<=top-1;i++){
        int y=0;
        for(int j=i+1;j<=top-1;j++){
            if(nm[i].y>nm[j].x&&nm[i].x<nm[j].x&&nm[i].y<nm[j].y){
                ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}