2026/5/28模拟——唐果

· · 个人记录

有一些低级错误,由于最后都在死磕第四题,没有留时间检查😓

P1042 [NOIP 2003 普及组] 乒乓球

1.没有判0:0的情况。
2.只判断了华华赢了的情况,没判对手赢时也要结束。

更正

#include <bits/stdc++.h>
using namespace std;
#define int long long
char c;
int a,b;
string s;
signed main()
{
    while(1)
    {
        cin >> c;
        if(c=='E') break;
        s+=c;
    }
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='W')
        {
            a++;
        }
        else
        {
            b++;
        }
        if(a>=11&&a-b>=2)
        {
            cout << a << ":" << b << endl;
            a=b=0;
        }
        else if(b>=11&&b-a>=2)
        {
            cout << a << ":" << b << endl;
            a=b=0;           
        }
    }
    cout << a << ":" << b << endl; 
    a=b=0;
    cout << endl;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='W')
        {
            a++;
        }
        else
        {
            b++;
        }
        if(a>=21&&a-b>=2)
        {
            cout << a << ":" << b << endl;
            a=b=0;
        }
        else if(b>=21&&b-a>=2)
        {
            cout << a << ":" << b << endl;
            a=b=0;           
        }        
    }
    cout << a << ":" << b << endl; 
    cout << endl;   
    return 0;
}

B3784 [语言月赛202306] 演唱会

额...有一个点要开关闭同步流😑😑😑

更正

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m,k,b,sx,maxn,mustid;
int a[105][100005];
struct node
{
    int x,id;
}res[100005];
int box[100005];
bool cmp(node x,node y)
{
    return x.x>y.x;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin >> n >> k >> m >> sx;
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin >> a[i][j];
            if(i==sx&&a[i][j]>=maxn)
            {
                maxn=a[i][j];
                mustid=j;
            }
            res[j].x+=a[i][j];
            res[j].id=j;
        }
    }
    sort(res+1,res+n+1,cmp);
    bool f=0;
    for(int i=1;i<=k;i++)
    {
        if(res[i].id==mustid)
        {
            cout << mustid << " ";
            f=1;
        }
    }
    if(f)
    {
        for(int i=1;i<=k;i++)
        {
            if(res[i].id!=mustid)
            {
                cout << res[i].id << " ";
            }
        }       
    }
    else
    {
        for(int i=1;i<k;i++)
        {
            cout << res[i].id << " ";
        }       
        cout << mustid << " ";
    }
    return 0;
}

P4924 [1007] 魔法少女小Scarlet

其实在考场上快写完了,最后一直在调代码,思路几乎一样,公式也推出来了,废话不多说,既然是模拟题,详见注释。

#include <bits/stdc++.h>
using namespace std;
int n,q,a[1005][1005],b[1005][1005],c[1005][1005];
void print()打印
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}
void shun(int sx,int sy,int r)//第i行第j列变成了倒数第i行的第j列
{
    for(int i1=sx,i2=1;i2<=r;i1++,i2++)//sx,sy是矩阵的左上、右上角
    {
        for(int j1=sy,j2=1;j2<=r;j1++,j2++)
        {
            b[i2][j2]=a[i1][j1];
        }
    }
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=r;j++)
        {
            c[j][r-i+1]=b[i][j];
        }
    }
    for(int i1=sx,i2=1;i2<=r;i1++,i2++)//我们需要拷贝一个备用数组,因为可能会覆盖,先把原来的存一下,方便计算。
    {
        for(int j1=sy,j2=1;j2<=r;j1++,j2++)
        {
            a[i1][j1]=c[i2][j2];
        }
    }
}
int main()
{
    cin >> n >> q;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            a[i][j]=(i-1)*n+j;
        }
    }
    while(q--)
    {
        int x,y,r,op;
        cin >> x >> y >> r >> op;
        if(!op) shun(x-r,y-r,2*r+1);//顺时针转一次
        else//逆时针转三次
        {
            shun(x-r,y-r,2*r+1);
            shun(x-r,y-r,2*r+1);
            shun(x-r,y-r,2*r+1);
        }
    }
    print();
}