8.2

· · 个人记录

卧的总结

这篇文章特别的水

未满126913467789岁🚫看

牢屎泰老6啦,让我们写文章!!!!!

错题修改

1.P9517 drink

错误原因

牢屎出的
不会

贞雀代码

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int l=n+1,r=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(x==1)
        {
            l=min(l,i);
            r=max(r,i);
        }
    }
    if(l==n+1&&r==0)cout<<0<<endl;
    else cout<<r-l+1;
    return 0;
}

2.P1639 [USACO18FEB] Teleportation B

错误原因

牢屎出的 不会

思路

只有两种可能:
    1.用传送门
    2.不用传送门
取min就可以了

真确代码

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a,b,x,y;
    cin>>a>>b>>x>>y;
    if(a>b)
    {
        swap(a,b);

    }
    if(x>y)
    {
        swap(x,y);

    }
    cout<<min(abs(a-x)+abs(b-y),b-a);
    return 0;
}

3.弹珠游戏

错误原因

牢屎出的 不会

死卤

有两种可能
    1.无容身之地
    2.有容身之地
        求行列
        取max可以啦

贞雀代码

#include<bits/stdc++.h>
using namespace std;
int a[1010][1010];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    int sum=0,maxn=INT_MIN;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(a[i][j]==0){
                for(int k=1;k<=n;k++){
                    if(a[i][k]!=0)sum+=a[i][k];
                }
                for(int k=1;k<=n;k++){
                    if(a[k][j]!=0)sum+=a[k][j];
                }
                if(sum>maxn)maxn=sum;
                sum=0;
            }
        }
    }
    cout<<maxn;
    return 0;
}

4.[海淀区小学组 2025] 拜访朋友

错误原因

牢屎出的 不会

死路

1.(x0 < x[1])x[n-1]-x0;
2.(x0 > x[n])x0-x[2];
3.
    min(
    往左
        1.x0-x[1]+x[n-1]-x[1]
        2.x0-x[2]+x[n]-x[2]
    往右
        1.x[n-1]-x0+x[n-1]-x[1]
        2.x[n]-x0+x[n]-x[2]
        )

真确垈马

#include<bits/stdc++.h>
using namespace std;
int x[100010];
int main()
{
    int n,x0;
    cin>>n>>x0;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i];

    }
    sort(x+1,x+n+1);
    if(n==1)
    {
        cout<<0<<endl;
        return 0;
    }
    if(x0<=x[1])
    {
        cout<<x[n-1]-x0;
    }
    else if(x0>=x[n])
    {
        cout<<x0-x[2];
    }
    else
    {
        int ans1=min(abs(x[n]-x0)+abs(x[n]-x[2]),abs(x[n-1]-x0)+abs(x[n-1]-x[1]));
        int ans2=min(abs(x[1]-x0)+abs(x[1]-x[n-1]),abs(x[2]-x0)+abs(x[n]-x[2]));
        cout<<min(ans1,ans2);
    }
    return 0;
}

5.P1803 凌乱的yyy / 线段覆盖

错误原因

牢屎出的 不会

真确垈马

#include<bits/stdc++.h>
using namespace std;
struct node
{
    int l,r;
}a[1000010];
bool cmp(node a,node b)
{
    return a.r<b.r;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].l>>a[i].r;
    }
    sort(a+1,a+n+1,cmp);
    int ans=1;
    int ed=a[1].r;
    for(int i=2;i<=n;i++)
    {
        if(a[i].l>=ed)
        {
            ed=a[i].r;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

6.

[USACO05NOV] 奶牛玩杂技

错误原因

不知道要a.s+a.w>b.s+b.w

司炉

bool cmp(aaa a,aaa b)
{

    if(a.as*a.bs!=b.as*b.bs)return a.as+a.bs<b.as+b.bs;

}

贞雀代码

#include<bits/stdc++.h>
using namespace std;
struct aaa
{
    long long as;
    long long bs;
}a[1000000];
bool cmp(aaa a,aaa b)
{

    if(a.as*a.bs!=b.as*b.bs)return a.as+a.bs<b.as+b.bs;

}
int main()
{
    long long n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].as>>a[i].bs;
    } 
    sort(a+1,a+n+1,cmp);
    long long cnt=LONG_LONG_MIN,ccnnr=0;
    for(int i=1;i<=n;i++)
    {
        ccnnr+=a[i-1].as;

        cnt=max(cnt,ccnnr-a[i].bs);

    } 
    cout<<cnt;
    return 0;
}

7.

牢屎出的 不会

错误原因:新芝士点我怎么知道。

错误代码:木有。

贞雀代码

牢屎泰老6啦,让我们写文章!!!!!

老屎🧑‍🏫肥肠聪明(✔️)

老屎🧑‍🏫是个大帅哥(❌)

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|### |

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

看到的是SB

不是SB的点下面

|

|

|

https://www.luogu.com.cn/paste/asbfig58

a

a

a

a