凌晨起来打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. oubango中视频JitterBuffer的优化

       

  2. box head上身旋转问题

    现有资源: 1.可旋转上身的动画,旋转角度左右各90度. 2.下身没有旋转动画(腿部左转右转动画) 使用场景: 1.整个模型随鼠标位置旋转,不使用上身旋转动画. 缺点:人物转向动画僵硬.  解决方案: ...

  3. Muduo 多线程模型:一个 Sudoku 服务器演变

    陈硕 (giantchen AT gmail) blog.csdn.net/Solstice Muduo 全系列文章列表: http://blog.csdn.net/Solstice/category ...

  4. Oracle 12C 新特性之在线重命名、迁移活跃的数据文件

    Oracle 数据库 12c 版本中对数据文件的迁移或重命名不再需要太多繁琐的步骤,可以使用 ALTER DATABASE MOVE DATAFILE 这样的 SQL 语句对数据文件进行在线重命名和移 ...

  5. Oracle 12c 多租户在 CDB 中 Plug A PDB,Unplugging A PDB

    Oracle 数据库 12 c 中介绍了多租户选项允许单个容器数据库 (CDB) 来承载多个单独的可插拔数据库 (PDB).本文简单的演示了如何在 CDB 中 Plug A PDB,Unpluggin ...

  6. [转]HTTP中cache-control的应用及说明

    网页的缓存是由http消息头中的“Cache-control”来控制的,常见的取值有private.no-cache.max-age.must-revalidate等,默认为private.其作用根据 ...

  7. redhat 安装lamp

    安装Apache yum install httpd 安装MySql yum install mysql mysql-server 安装php yum install php 安装php的mysql模 ...

  8. 随机数 while循环 do while循环 for循环

    1.随机数   arc4random()    返回一个随机数 如果要随机[a,b]范围内的随机数   arc4random() % (b - a + 1) +  a ; 2.break  跳出本次循 ...

  9. 七 内置锁 wait notify notifyall; 显示锁 ReentrantLock

    Object中对内置锁进行操作的一些方法: Java内置锁通过synchronized关键字使用,使用其修饰方法或者代码块,就能保证方法或者代码块以同步方式执行. 内置锁使用起来非常方便,不需要显式的 ...

  10. js---数组习题---

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...