A.
不满足一个即可
// Problem: A. Tricky Template
// Contest: Codeforces - Educational Codeforces Round 161 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1922/problem/0
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void Lan(){
int n;
cin>>n;
string a,b,c;
cin>>a>>b>>c;
for(int i=0;i<n;i++){
if(a[i]==b[i] && a[i]!=c[i]){
cout<<"YES"<<'\n';
return;
}else if(a[i]!=b[i] && a[i]!=c[i] && b[i]!=c[i]){
cout<<"YES"<<'\n';
return;
}
}
cout<<"NO"<<'\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
B.
1.x=y=z;C(3,n)
2.x<y=z;C(2,n)*(前缀和)
// Problem: B. Forming Triangles
// Contest: Codeforces - Educational Codeforces Round 161 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1922/problem/B
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
ll a[N];
void Lan(){
int n;
cin>>n;
for(int i=0;i<=n;i++){
a[i]=0;
}
for(int i=1;i<=n;i++){
int x;
cin>>x;
a[x]++;
}
ll ans=0;
ll tot=0;
for(int i=0;i<=n;i++){
ans+=a[i]*(a[i]-1)*(a[i]-2)/6;
ans+=a[i]*(a[i]-1)/2*tot;
tot+=a[i];
}
cout<<ans<<'\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
C.
处理一下最近城市
然后前缀和计算
// Problem: C. Closest Cities
// Contest: Codeforces - Educational Codeforces Round 161 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1922/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
ll a[N],l[N],r[N];
void Lan(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<n;i++){
int rdis=a[i+1]-a[i];
int ldis=a[i]-a[i-1];
if(rdis<ldis || i==1){
r[i]=1;
}else{
r[i]=rdis;
}
}
for(int i=2;i<=n;i++){
int rdis=a[i+1]-a[i];
int ldis=a[i]-a[i-1];
if(rdis>ldis || i==n){
l[i]=1;
}else{
l[i]=ldis;
}
}
l[n+1]=0;
for(int i=1;i<=n;i++){
r[i]+=r[i-1];
}
for(int i=n;i>=1;i--){
l[i]+=l[i+1];
}
int m;
cin>>m;
while(m--){
int x,y;
cin>>x>>y;
if(x<=y){
cout<<r[y-1]-r[x-1]<<'\n';
}else{
cout<<l[y+1]-l[x+1]<<'\n';
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}