正睿暑期培训day3考试

链接

A

可以发现一个小棍的贡献是使得左右两列上的球位置互换。所以只要找出哪两个球会经过当前位置,然后swap一下就行了。。

考场上调了2.5h,依然没过样例。赛后发现忘了排序!!!!。。。

/*
* @Author: wxyww
* @Date: 2019-08-06 08:19:23
* @Last Modified time: 2019-08-06 18:45:46
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

ll read() {
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9') {
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
int h,w,n;
namespace BF2 {
    const int N = 200000 + 100;
    int a[N];
    int getr(int p,int x) {
        p = p + x % (2 * w);
        if(p > 2 * w) return p - 2 * w;
        if(p > w) return w - (p - w - 1);
        return p;
    }
    int getl(int p,int x) {
        p = p - x % (2 * w);
        if(p <= -w) return p + w * 2;
        if(p <= 0) return -p + 1;
        return p;
    }
    struct NODE {
        int x,y;
    }q[N];
    bool cmp(const NODE &A,const NODE &B) {
        return A.y > B.y;
    }
    void main() {
        for(int i = 1;i <= w;++i) {
            if(i & 1) a[i] = getr(i,h);
            else a[i] = getl(i,h);
        }
        
        for(int i = 1;i <= n;++i) q[i].y = read(),q[i].x = read();

        sort(q + 1,q + n + 1,cmp);

        for(int i = 1;i <= n;++i) {
            int y = q[i].y,x = q[i].x;

                swap(a[getl(x,y - 1)],a[getr(x,y)]);
        }
        for(int i = 1;i <= w;++i) printf("%d\n",a[i]);
    }
}
int main() {
    h = read(),w = read(),n = read();
        BF2::main();

    return 0;
}

B

挺智商的一道题。

首先猜个结论。就是这张图的形态一定是确定的。也就是说根据他给出的点数限制和路线的要求,我们可以确定出所有走过的格子(如果有解的话)。某大佬提供了一个非常好的求解这张图的方法:让两个点同时走,其中一个尽量往右走,另外一个尽量往左走。

求出这张图之后,只要找出两条路径相交(指第一次相交)的点个数cnt,答案即为\(2^{cnt}\)

/*
* @Author: wxyww
* @Date: 2019-08-06 10:18:48
* @Last Modified time: 2019-08-06 17:23:12
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 200010,mod = 1e9 + 7;
ll read() {
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9') {
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
int a[N],b[N];
int main() {
    int T = read();
    while(T--) {
        int n = read();
        for(int i = 1;i <= n;++i) a[i] = read();
        for(int i = 1;i <= n;++i) b[i] = read();
        int x1 = 1,x2 = 1,y1 = 1,y2 = 1;
        a[1]--;b[1]--;
        int ans = 1;
        int bz = 0;
        while(x1 != n || y1 != n) {
            int flag = (x1 == x2);
            if(a[x1] && b[y1 + 1]) ++y1;
            else if(a[x1 + 1] && b[y1]) ++x1;
            else {bz = 1;break;}
            if(a[x2 + 1] && b[y2]) ++x2;
            else if(a[x2] && b[y2 + 1]) ++y2;
            else {bz = 1;break;}
            a[x1]--;b[y1]--;
            if(x1 == x2) {
                if(!flag) ans = ans * 2 % mod;
            }
            else a[x2]--,b[y2]--;
        }
        for(int i = 1;i <= n;++i) if(a[i] != 0 || b[i] != 0) bz = 1;
        if(bz) puts("0");
        else {
            printf("%d\n",ans);
        }
    }

    return 0;
}

C

尝鲜vector新用法,然后惨爆零。。。。

因为这是一颗树。所以一条边所连的两个点只能通过这条边进行信息交流。记假设当前某条边x所连接的两个点为\(u,v\)。且这个连通块中包含的信息数量为t,然后断开这条边,之后u和v包含的信息数量都可能会增加。如果再次连回这条边的时候\(u,v\)包含的信息数量分别为\(f_u,f_v\)。那么重新连接之后这个连通块所包含的信息数量就是\(f_u+f_v-t\)。用\(LCT\)维护即可。

/*
* @Author: wxyww
* @Date: 2019-08-06 10:56:01
* @Last Modified time: 2019-08-06 20:31:40
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
#define ls TR[cur].ch[0]
#define rs TR[cur].ch[1]
const int N = 200000 + 100;
ll read() {
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9') {
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}

struct NODE {
    int ch[2],pre,val,ans,rev;
}TR[N];
int isroot(int cur) {
    return TR[TR[cur].pre].ch[0] != cur && TR[TR[cur].pre].ch[1] != cur;
}
void pushdown(int cur) {
    if(TR[cur].rev) {
        TR[ls].rev ^= 1;TR[rs].rev ^= 1;
        swap(ls,rs);
        TR[cur].rev = 0;
    }
}
void PUSHD(int cur) {
    if(!isroot(cur)) PUSHD(TR[cur].pre);
    pushdown(cur);
}
int getwh(int cur) {
    return TR[TR[cur].pre].ch[1] == cur;
}
void rotate(int cur) {
    int fa = TR[cur].pre,gr = TR[fa].pre,f = getwh(cur);
    TR[cur].pre = gr;
    if(!isroot(fa)) TR[gr].ch[getwh(fa)] = cur;
    TR[TR[cur].ch[f ^ 1]].pre = fa;
    TR[fa].ch[f] = TR[cur].ch[f ^ 1];
    TR[fa].pre = cur;
    TR[cur].ch[f ^ 1] = fa;
}
int ans[N],top,sta[N];
void splay(int cur) {
    PUSHD(cur);
    while(!isroot(cur)) {
        if(!isroot(TR[cur].pre)) {
            if(getwh(TR[cur].pre) == getwh(cur)) rotate(TR[cur].pre);
            else rotate(cur);
        }
        rotate(cur);
    }
    // pushup(cur);
}

void access(int cur) {
    int t = 0;
    while(cur) {
        splay(cur);
        rs = t;t = cur;
        // pushup(cur);
        cur = TR[cur].pre;      
    }
}

int findroot(int cur) {
    access(cur);splay(cur);
    while(ls) pushdown(cur),cur = ls;
    return cur;
}
void makeroot(int cur) {
    int v = ans[findroot(cur)];
    access(cur);splay(cur);
    TR[cur].rev ^= 1;
    pushdown(cur);
    ans[cur] = v;
}
void link(int x,int y) {
    makeroot(x);
    TR[x].pre = y;
}
void cut(int x,int y) {
    makeroot(x);
    access(y);splay(y);
    TR[x].pre = TR[y].ch[0] = 0;
    ans[findroot(y)] = ans[x];
}
int n,m,q;
int tmp[N],L[N],R[N],vis[N];
int main() {
    // freopen("1.in","r",stdin);
    n = read(),m = read(),q = read();
    for(int i = 1;i < n;++i){
        L[i] = read(),R[i] = read();
    }
    for(int i = 1;i <= n;++i) ans[i] = 1;
    for(int i = 1;i <= m;++i) {
        int t = read();
        int x = L[t],y = R[t];
        if(vis[t]) {
            tmp[t] = ans[findroot(x)];
            cut(x,y);
        }
        else {
            int k1 = ans[findroot(x)],k2 = ans[findroot(y)];
            link(x,y);
            ans[findroot(x)] = k1 + k2 - tmp[t];
        }
        vis[t] ^= 1;
    }
    for(int i = 1;i <= q;++i) {
        printf("%d\n",ans[findroot(read())]);
    }

    return 0;
}

总结

考场上千万不要用平常没用过的技巧!!!

T1jiaoji了两个小时,浪费太多时间。

T3第二档30分想出做法了,一兴奋就忘了写???!!!。。。

T2搜索不好好搜。。。明明是搜索的复杂度,还要套个没用的dp,,,花式作死。

转载于:https://www.cnblogs.com/wxyww/p/11311955.html

深度学习是机器学习的一个子领域,它基于人工神经网络的研究,特别是利用多层次的神经网络来进行学习和模式识别。深度学习模型能够学习数据的高层次特征,这些特征对于图像和语音识别、自然语言处理、医学图像分析等应用至关重要。以下是深度学习的一些关键概念和组成部分: 1. **神经网络(Neural Networks)**:深度学习的基础是人工神经网络,它是由多个层组成的网络结构,包括输入层、隐藏层和输出层。每个层由多个神经元组成,神经元之间通过权重连接。 2. **前馈神经网络(Feedforward Neural Networks)**:这是最常见的神经网络类型,信息从输入层流向隐藏层,最终到达输出层。 3. **卷积神经网络(Convolutional Neural Networks, CNNs)**:这种网络特别适合处理具有网格结构的数据,如图像。它们使用卷积层来提取图像的特征。 4. **循环神经网络(Recurrent Neural Networks, RNNs)**:这种网络能够处理序列数据,如时间序列或自然语言,因为它们具有记忆功能,能够捕捉数据中的时间依赖性。 5. **长短期记忆网络(Long Short-Term Memory, LSTM)**:LSTM 是一种特殊的 RNN,它能够学习长期依赖关系,非常适合复杂的序列预测任务。 6. **生成对抗网络(Generative Adversarial Networks, GANs)**:由两个网络组成,一个生成器和一个判别器,它们相互竞争,生成器生成数据,判别器评估数据的真实性。 7. **深度学习框架**:如 TensorFlow、Keras、PyTorch 等,这些框架提供了构建、训练和部署深度学习模型的工具和库。 8. **激活函数(Activation Functions)**:如 ReLU、Sigmoid、Tanh 等,它们在神经网络中用于添加非线性,使得网络能够学习复杂的函数。 9. **损失函数(Loss Functions)**:用于评估模型的预测与真实值之间的差异,常见的损失函数包括均方误差(MSE)、交叉熵(Cross-Entropy)等。 10. **优化算法(Optimization Algorithms)**:如梯度下降(Gradient Descent)、随机梯度下降(SGD)、Adam 等,用于更新网络权重,以最小化损失函数。 11. **正则化(Regularization)**:技术如 Dropout、L1/L2 正则化等,用于防止模型过拟合。 12. **迁移学习(Transfer Learning)**:利用在一个任务上训练好的模型来提高另一个相关任务的性能。 深度学习在许多领域都取得了显著的成就,但它也面临着一些挑战,如对大量数据的依赖、模型的解释性差、计算资源消耗大等。研究人员正在不断探索新的方法来解决这些问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值