C 小红下象棋  为了不初始化一堆数据,用 for 循环来折磨自己,写着写着逻辑自己都懵逼了
不过结果是好的,时空复杂度都很低
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pl;
const int N=110,M=998244353;
int t;
int sum,n;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>t;
    int a[]={-2,2},b[]={-1,+1},c[]={-1,1,0,0};
    while (t--) {
        int x,y,n;
        cin>>x>>y>>n;
        set<pl>ss;
        vector<pl>ve;
        bool oo=false;
        for (int i=0;i<3;i++) {
            for (int j=0;j<3;j++) {
                    ve.push_back({x+c[i],y+c[j]});
            }
        }
        while (n--) {
            int x1,y1;
            cin>>x1>>y1;
            for (int i=0;i<2;i++) {
                for (int j=0;j<2;j++) {
                    for (int k=0;k<ve.size();k++) {
                        if ((x1+a[i]==ve[k].first&&y1+b[j]==ve[k].second)||(y1+a[i]==ve[k].second&&x1+b[j]==ve[k].first)) {
                            ss.insert({ve[k].first,ve[k].second});
                        }
                    }
                }
            }
        }
            if (ss.size()==8&&(!ss.count({x,y})))cout<<'A'<<endl;
            else if (ss.size()==9)cout<<'B'<<endl;
            else cout<<'C'<<endl;
    }
    return 0;
}

https://ac.nowcoder.com/acm/contest/123787/C