凌晨起来打CF,0:05,也是我第一次codeforces

第一题:

我刚开始怀疑自己读错题了,怎么会辣么水。

判除了0的数字种类

#include <cstdio>
;
];
int main(){
    scanf("%d",&n);int i;
    ;i<=n;++i){
        ;
    }
    printf("%d",ans);
}

第二题:让你找一个x使x<=y且x不能被[2,p]内的数整除,使x尽量大

其实是暴力枚举。

#include <cstdio>
int p,y;
bool ck(int x){
    int i;
    ;i*i<=x&&i<=p;++i));
    ;
}
int main(){
    scanf("%d%d",&p,&y);
    int i;
    for(i=y;i>p;--i)if(ck(i)){
        printf("%d",i);
        ;
    }
    printf("-1");
}

第三题,模拟题,太水了,不细说:

#include <cstdio>
#include <iostream>
using namespace std;
long long k,d,t;
;
int main(){
    scanf(){
        printf("%I64d",t);
        ;
    }
    )*d;tmp-=k;
    ;
    long long tm=(long long)((double)t/(x+y));ans=tm*(k+tmp);double rt=(double)t-(double)tm*(x+y);
    if(rt<=k){
        ans+=rt;printf("%lf",ans);
    }else{
        ans+=k;rt-=k;ans+=rt*(;printf("%lf",ans);
    }
}

第四题:

给你一个有向图,问你能否奇数步走到一个初度为0的点,输出路径

初看吓得我以为是SG函数,然而并不是, tarjan+bfs就行了

bfs和dp一起来,这里的dp可以用spfa的方式,用一个可以让元素多次进出的队列,然后搞dp

tarjan用来判能不能平局,如果s以后的路上没有scc,就输出lose

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define maxn 100010
#define maxm 200010
struct edge{int nxt,to;}e[maxm];
];
],inq[maxn];
void add(int u,int v){e[++pos]=(edge){head[u],v},head[u]=pos;}
stack<int>s;
queue<int>q;
void tar(int u){
    dnf[u]=low[u]=++dfs_cnt;s.push(u);int i;
    for(i=head[u];i;i=e[i].nxt){
        int v=e[i].to;
        if(!dnf[v]){
            tar(v);low[u]=min(low[u],low[v]);
        }else if(!scc[v])low[u]=min(low[u],dnf[v]);
    }
    if(low[u]==dnf[u]){
        for(scc_cnt++;;){
            int x=s.top();s.pop();++scc_size[scc_cnt];
            scc[x]=scc_cnt;if(x==u)break;
        }
    }
}
void dfs(int u,int sta){
    if(u){
        dfs(pre[u][sta],sta== ? :);
        ans[++ans[]]=u;
    }
}
int main(){
    scanf("%d%d",&n,&m);int i;
    ;i<=n;++i){
        int k,x;scanf("%d",&k);
        while(k--){
            scanf("%d",&x);add(i,x);++out[i];
        }
    }
    scanf("%d",&st);
    ;i<=n;++i)if(!dnf[i])tar(i);
    ;
    dp[st][]=;q.push(st);inq[st]=;
    while(!q.empty()){
        ;
        )flg=;
        for(i=head[u];i;i=e[i].nxt){
            int v=e[i].to;
            ] && dp[v][]==){
                dp[v][]=;pre[v][]=u;;
            }
            ] && dp[v][]==){
                dp[v][]=;pre[v][]=u;;
            }
        }
    }
    ;i<=n;++i)] && ){
        dfs(i,);printf("Win\n");
        ;j<=ans[];++j)printf(;
    }
    if(flg)printf("Draw");else printf("Lose");
}

T5:构造题

题意是给定一个字符串S1,S2(这不是两个吗。。。)长度2e3以下

定义操作:

将s1的后缀x个进行一次反转,再放到字符串首

如果操作多余6100,则答案无效

分析:

对于一个字符串:ABxC(A:与s2后缀相符的字符串,x:S2后缀A之前的那个字符,也就是我们要将x放到A前面,B,C:都是无关紧要的乱序字符串)

ABxC->CxBA(每个都反转)->ABCx->xABC 操作次数3n

#include <cstdio>
#include <cstring>
using namespace std;
#define maxn 2010
char s1[maxn],s2[maxn];
],h1[],h2[];
int idx(char c){return c-'a';}
bool jg(){
    ;i<n;++i);
    ;
}
bool ck(int l1,int r1,int l2,int r2){
    ;
    ;
}
int main(){//freopen("o1.txt","w",stdout);
    scanf("%d",&n);
    scanf(;
    int i;
    ;i<n;++i)h1[idx(s1[i])]++,++h2[idx(s2[i])];
    ;i<;++i)if(h1[i]!=h2[i]){
        printf(;
    }
    while(!jg()){
        ,bpos=-,cpos=-,xpos=-;
        ,i-,n-i,n-);--i);len=i;
        apos=len-;
        ;s1[i]!=s2[n-len-];++i);
        bpos=i-;xpos=i;cpos=n;
        ans[++ans[]]=n;ans[++ans[]]=bpos+;ans[++ans[]]=;
        char tmp[maxn];
        tmp[]=s2[n-len-];;
        ;i<=apos;++i)tmp[++ps]=s1[i];
        ;i<=bpos;++i)tmp[++ps]=s1[i];
        //for(i=xpos+1;i<n;++i)tmp[++ps]=s1[i];
        ;i>=xpos+;--i)tmp[++ps]=s1[i];
        ;i<n;++i)s1[i]=tmp[i];
    }
    printf(]);
    ;i<=ans[];++i)printf("%d ",ans[i]);
}

Codeforces Round #467(Div2)题解的更多相关文章

  1. [Codeforces Round #461 (Div2)] 题解

    [比赛链接] http://codeforces.com/contest/922 [题解] Problem A. Cloning Toys          [算法] 当y = 0 ,   不可以 当 ...

  2. CodeForces round 967 div2 题解(A~E)

    本来准备比完赛就写题解的, 但是一拖拖了一星期, 唉 最后一题没搞懂怎么做,恳请大神指教 欢迎大家在评论区提问. A Mind the Gap 稳定版题面 https://cn.vjudge.net/ ...

  3. Codeforces Round #407 div2 题解【ABCDE】

    Anastasia and pebbles 题意:你有两种框,每个框可以最多装k重量的物品,但是你每个框不能装不一样的物品.现在地面上有n个物品,问你最少多少次,可以把这n个物品全部装回去. 题解:其 ...

  4. Codeforces Round#704 Div2 题解(A,B,C,D,E)

    FST ROUND !!1 A Three swimmers: 直接整除一下向上取整就好了: #include <bits/stdc++.h> using namespace std; t ...

  5. Codeforces Round#687 Div2 题解

    打这场的时候迷迷糊糊的,然后掉分了( A Prison Break: 题面很复杂,但是题意很简单,仅需求出从这个点到四个角的最大的曼哈顿距离即可 #include <bits/stdc++.h& ...

  6. CodeForces Round #516 Div2 题解

    A. Make a triangle! 暴力... 就是给你三个数,你每次可以选一个加1,问最少加多少次能构成三角形 #include <bits/stdc++.h> #define ll ...

  7. Codeforces Round #467 (div.2)

    Codeforces Round #467 (div.2) 我才不会打这种比赛呢 (其实本来打算打的) 谁叫它推迟到了\(00:05\) 我爱睡觉 题解 A. Olympiad 翻译 给你若干人的成绩 ...

  8. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  9. Codeforces Round #543 Div1题解(并不全)

    Codeforces Round #543 Div1题解 Codeforces A. Diana and Liana 给定一个长度为\(m\)的序列,你可以从中删去不超过\(m-n*k\)个元素,剩下 ...

随机推荐

  1. 流媒体直播服务器:Bull-Live-Server

    Bull Live Server 简称 BLS ,旨在使用C++语言提供强大功能和高性能的流媒体直播服务器. 为何要写 BLS ? 1.simple rtmp server https://githu ...

  2. Gym - 101196:F Removal Game(区间DP)

    题意:一个环状数组,给定可以删去一个数,代价的相邻两个数的gcd,求最小代价. 思路:区间DP即可,dp[i][j]表示[i,j]区间只剩下i和j时的最小代价,那么dp[i][j]=min  dp[i ...

  3. tomcat可以访问默认页面,但是无法访问webapp下的指定项目

     tomcat可以访问默认页面,但是无法访问webapp下的指定项目 1.注意下安装tomcat时的默认端口,8005,8009,8080,我这边没有修改,根据需要自行修改,确保tomcat可以启动 ...

  4. bzoj 3172: [Tjoi2013]单词 fail树

    题目大意: 一篇论文是由许多单词组成,现在想知道每个单词分别在论文中出现多少次. 题解: 我们首先考虑fail指针的含义 如果fail[x] = y,那么我们就知道y作为x的后缀在x中出现了一次 所以 ...

  5. Dexdump 无法正常反编译问题

    WIN环境下无法正常运行,提示Unable open XXX as zip 解决方案:使用APKTOOL + JD-GUI进行替代反编译

  6. [poj3311]Hie with the Pie(Floyd+状态压缩DP)

    题意:tsp问题,经过图中所有的点并回到原点的最短距离. 解题关键:floyd+状态压缩dp,注意floyd时k必须在最外层 转移方程:$dp[S][i] = \min (dp[S \wedge (1 ...

  7. 向PCD文件写入点云数据

    博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=83 本小节我们学习如何向PCD文件写入点云数据. 代码 章例2文件夹中,打开 ...

  8. sklearn保存模型

    # View more python tutorials on my Youtube and Youku channel!!! # Youtube video tutorial: https://ww ...

  9. ASP.NET Core 身份认证 (Identity、Authentication)

    Authentication和Authorization 每每说到身份验证.认证的时候,总不免说提及一下这2个词.他们的看起来非常的相似,但实际上他们是不一样的. Authentication想要说明 ...

  10. 1. csrf 简介

    浅谈CSRF CSRF是什么? (Cross Site Request Forgery, 跨站域请求伪造)是一种网络的攻击方式,它在 年曾被列为互联网 大安全隐患之一,也被称为“One Click A ...