重载运算符
C++struct node{
int x,y;
friend bool operator < (node p,node q){
if(p.x!=q.x)return p.x<q.x;
return p.y<q.y
}
friend bool operator > (node p,node q){
if(p.x!=q.x)return p.x>q.x;
return p.y>q.y
}
};
C++#include<bits/stdc++.h>
using namespace std;
string s;
map <string,int> m;
int t,ans;
signed main(){
cin>>s>>t;
while(t--){
string a;
cin>>a;
sort(a.begin(),a.end());
m[a]++;
}
for(int i=0;i+7<=(int)s.size();i++){
string b=s.substr(i,8);
sort(b.begin(),b.end());
ans+=m[b];
}
printf("%d",ans);
return 0;
}
/*
1 ≤n ≤1000
*/
C++#include<bits/stdc++.h>
#define pb push_back
#define int long long//好习惯
using namespace std;
int n,d,k,mx;
vector <int> v[100005];
signed main(){
scanf("%lld%lld%lld",&n,&d,&k);
for(int i=1;i<=n;i++){
int ts,id;
scanf("%lld%lld",&ts,&id);
v[id].pb(ts);
mx=max(mx,id);
}
for(int i=0;i<=mx;i++){
sort(v[i].begin(),v[i].end());
int l=0,r=k-1;
bool fl=0;
while(!fl&&r<v[i].size()){
if(v[i][r]<d+v[i][l]){
fl=1;
printf("%lld\n",i);
}
l++;
r++;
}
}
return 0;
}
/*
id =0
数组 1e5
感觉 1e5*1e5 要用龙龙
*/
C++#include<bits/stdc++.h>
#define lb lower_bound
#define ub upper_bound
const int inf=1e9+7;
using namespace std;
set <int> n[400005];
set <int> m[400005];
int h,w,q,ans;
void de(int x,int y){
if(x==-inf||x==inf||y==-inf||y==inf)return;
n[x].erase(y);
m[y].erase(x);
return ;
}
signed main(){
scanf("%d%d%d",&h,&w,&q);
for(int i=1;i<=h;i++){
n[i].insert(-inf);
for(int j=1;j<=w;j++){
n[i].insert(j);
}
n[i].insert(inf);
}
for(int i=1;i<=w;i++){
m[i].insert(-inf);
for(int j=1;j<=h;j++){
m[i].insert(j);
}
m[i].insert(inf);
}
while(q--){
int x,y;
scanf("%d%d",&x,&y);
if(n[x].count(y)){//删过
de(x,y);
}
else{//没删过
//左
auto it=n[x].lb(y);
de(x,*it);
//右
it--;
de(x,*it);
//上!!
it=m[y].lb(x);
de(*it,y);
//下
it--;
de(*it,y);
}
}
for(int i=1;i<=h;i++){
ans+=n[i].size()-2;
}
printf("%d",ans);
return 0;
}
/*
*/