Codeforces Round 864 (Div. 2)

题解报告

基本的一些理解和问题都在注释中
A:Li Hua and Maze
就是判断把其中一个点围起来所需要的最小的格子,考虑下边界的情况就行了

#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int T;cin>>T;
    while(T--)
    {
        int N,M;cin>>N>>M;
        int X1,Y1,X2,Y2;
        cin>>X1>>Y1>>X2>>Y2;
        int res1=4,res2=4;
        if(X1==1||X1==N)res1--;
        if(Y1==1||Y1==M)res1--;
        if(X2==1||X2==N)res2--;
        if(Y2==1||Y2==M)res2--;
        cout<<min(res1,res2)<<endl;
    }
    return 0;
}

B:Li Hua and Pattern
就是把不同的加起来,然后看看够不够变,如果够的话剩下的能不能完全用上
注意一奇偶就没什么问题

#include <bits/stdc++.h>//注意奇偶的判断就好
using namespace std;
const int maxn=1e3+10;
int num[maxn][maxn];
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int T;cin>>T;
    while(T--)
    {
        int N,K;cin>>N>>K;
        for(int i=0;i<N;i++)
            for(int j=0;j<N;j++)cin>>num[i][j];
        int res=0;
        for(int i=0;i<(N+1)/2;i++)
        {
            for(int j=0;j<N;j++)
            {
                if((N&1)&&i==(N+1)/2-1&&j>N/2)break;
                if(num[i][j]!=num[N-i-1][N-j-1])res++;
            }
        }
        if(K<res)cout<<"NO"<<endl;
        else{
            if(N&1)cout<<"YES"<<endl;
            else{
                if((K-res)%2==0)cout<<"YES"<<endl;
                else cout<<"NO"<<endl;
            }
        }
    }
    return 0;
}

C:Li Hua and Chess
按照题目意思,一个点到 \((1,1)\) 的距离 \(Dx+1\) 不是该点的 \(X\) 坐标就是 \(Y\) 坐标,然后通过 \((1,Dx)\)\((Dx,1)\) 来判断是 \(X\) 坐标还是 \(Y\) 坐标就好了,注意边界的判断

#include <bits/stdc++.h>
using namespace std;
int Ask(int X,int Y)
{
    int res;
    cout<<"? "<<X<<" "<<Y<<endl;//每次输出后要cout.flush()
    cout.flush();cin>>res;
    return res;
}
void Res(int X,int Y)
{
    cout<<"! "<<X<<" "<<Y<<endl;
    cout.flush();
}
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int T;cin>>T;
    while(T--)
    {
        int N,M;cin>>N>>M;
        int D1=Ask(1,1);
        if(D1>=N){
            int D2=Ask(1,D1+1);
            Res(D2+1,D1+1);
        }else if(D1>=M){
            int D2=Ask(D1+1,1);
            Res(D1+1,D2+1);
        }else{
            int D2=Ask(1,D1+1);
            int D3=Ask(D1+1,1);
            if(D2<D1)Res(D2+1,D1+1);
            else if(D3<D1)Res(D1+1,D3+1);
            else Res(D1+1,D1+1);
        }
    }
    return 0;
}

其它题目不会,开摆!!!

posted @ 2023-04-10 18:09  WUTONGHUA02  阅读(26)  评论(0编辑  收藏  举报