希望,不要还有一天像今天一样糟糕。

T1 three strings

笔记本的google 炸了,读题可难受了

多组测试数据

我们的想法是,用string存字符串,若 对于任意的i,a[i],b[i],c[i]里没有至少两个相同,那么就不是,反之是对

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define fake int
using namespace std;
int read(){
    int x=0;bool f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=1;
        ch=getchar();
    }
    while(ch<='9'&&ch>='0'){
        x=(x<<1)+(x<<3)+(ch-'0');
        ch=getchar();
    }
    return x;
}
char Get(){
    char ch=getchar();
    while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
    return ch;
}
const int Maxn=1e5+111;
string Getstr(){
    string x;
    char ch=getchar();
    while(ch<'a'||ch>'z'){
        ch=getchar();
    }
    while(ch<='z'&&ch>='a'){
        x+=ch;
        ch=getchar();
    }
    return x;
}
int n;
string a,b,c;

bool flag;
int main(){
//  freopen("ret.in","r",stdin);
    n=read();
    while(n--){
        flag=1;
        a=Getstr();b=Getstr();c=Getstr();
        for(int i=0;i<a.size();i++){
            char aa,bb,cc;
            aa=a[i],bb=b[i],cc=c[i];
            if(aa==cc||bb==cc){
                continue;
            }
            else {
                flag=0;
                break;
            }
        }
        if(flag){
            printf("YES\n");
        }
        else printf("NO\n");
    }
    return 0;
}

T2 Motarack's Birthday

其实这个题挺坑的。。WA了2次,又掉rating了。。。。

我这题的想法想到了平均。。。但其实不是。。应该是一个中位数。。。

准确的说。我们先找出没有丢的相邻数之差的最大绝对值,然后对于每一个pair\(<a_i,-1>\),其中\(a_i\)!=-1,进行关于\(a_i\)的排序,找到这些询问的中位数,

最后绝对值的最大值应该拿中位数根两边的比一下,在跟已知的最大值比一下即可。最后 k即为这个中位数

还要特判,就是全是-1的时候直接输出0 0

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <map>
#include <queue>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define fake int
using namespace std;
int read(){
    int x=0;bool f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=1;
        ch=getchar();
    }
    while(ch<='9'&&ch>='0'){
        x=(x<<1)+(x<<3)+(ch-'0');
        ch=getchar();
    }
    return f?-x:x;
}
char Get(){
    char ch=getchar();
    while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
    return ch;
}
const int Maxn=1e5+111;
ll n,k,t,a[Maxn],max1;
struct Node{
    ll f,s;
}p[Maxn];
bool flag;
bool cmp(Node a,Node b){
    return a.s<b.s;
}
int main(){
//  freopen("ret.in","r",stdin);
    t=read();
    while(t--){
        n=read();bool flag=0;a[0]=0;
        for(int i=1;i<=n;i++) {
            a[i]=read();
            if(a[i]!=-1) flag=1;
        }a[n+1]=0;
        if(!flag){
            printf("0 0\n");
            continue;
        }
        max1=0;
        for(int i=1;i<n;i++)
            if(a[i]!=-1&&a[i+1]!=-1) max1=max(max1,abs(a[i]-a[i+1]));
        int cnt=0;
        for(int i=1;i<n;i++){
            if(!((a[i]!=-1&&a[i+1]!=-1)||(a[i]==-1&&a[i+1]==-1))){
                p[++cnt].f=-1;
                p[cnt].s=max(a[i],a[i+1]);
            }
        }
        sort(p+1,p+1+cnt,cmp);
        ll pp=(p[1].s+p[cnt].s)/2;
        printf("%lld %lld\n",max(p[cnt].s-pp,max(max1,pp-p[1].s)),pp);
    }
    return 0;
}

T3 Ayoub's function

我们反向思维,他让我统计包含1的子段最多,我们考虑全是0的字段最少。

证明引理

下面数竞党的福利
\[
\forall a,b,n \in N^+且 a+b=n,则必有 a(a+1)+b(b+1) \ge \lceil \frac {n}{2} \rceil*\lceil \frac {n+1}{2} \rceil+\lfloor \frac {n}{2} \rfloor*\lfloor \frac {n+1}{2} \rfloor
\]
我们对n的奇偶性做讨论

再n为偶数时 ,原式变为
\[
a(a+1)+(n-a)(n-a+1) \ge \frac {n^2} {2}
\]
运用琴生不等式并同时构造辅助函数\(f(x)=x(x+1)\),显然此函数是下凸的,于是原不等式变为
\[
\frac {f(a)+f(n-a)}{2} \ge f(\frac{n}{2})
\]
由琴生不等式,这几乎是显然的

再把合理的推广到多元

于是可以证毕。故而能贪心。于是这题就能为转化为 给你一些令 分成较平均几段,算总子段的个数,最后一减就行了

ps:因为和谐了

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <map>
#include <queue>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define fake int
using namespace std;
int read(){
    int x=0;bool f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=1;
        ch=getchar();
    }
    while(ch<='9'&&ch>='0'){
        x=(x<<1)+(x<<3)+(ch-'0');
        ch=getchar();
    }
    return f?-x:x;
}
char Get(){
    char ch=getchar();
    while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
    return ch;
}
const ll Maxn=1e9+11;
ll t,n,m,ans;
int main(){
//  freopen("ret.in","r",stdin);
    t=read();
    while(t--){
        n=read();m=read();
        if(m==0){
            printf("0\n");
            continue;
        }
        ans=n*(n+1)/2;
        ll m1=n-m;//0
        ll x=(m1)/(m+1);//һ�μ���
        ll q=x*(m+1);//���ڼ���
        ll sum=m1-q;
        ans-=x*(x+1)/2*(m+1-sum);
        ans-=(x+1)*(x+2)/2*(sum);
        printf("%lld\n",ans);
    }
    return 0;
}

T4 Time to Run

1-一直往前走,直到到达第一行的最后一列。
2-继续向左走,直到你再次到达第一行的第一列。
3-下去。
4-一直往前走,直到到达当前行的最后一列。
5-继续{向上,向下,向左}前进,直到再次到达当前行的第一列。
6-如果你位于最后一行,请继续向上直到再次到达左上方的单元格,否则重复第3、4和5步。

注意会有坑点,比如他的宽度是一

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <deque>
#include <queue>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
#include <list>
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define fake int
#define get() getchar()
#define size 666
using namespace std;
int read(){
    int x=0;
    char ch=get();
    while(ch<'0'||ch>'9') ch=get();
    while(ch<='9'&&ch>='0'){
        x=(x<<1)+(x<<3)+(ch-'0');
        ch=get();
    }
    return x;
}
int n,m,k;

int main(){
//  freopen("Time to Run.in","r",stdin);
    n=read();m=read();k=read();
    if(k>4*m*n-2*m-2*n){
        printf("NO");
        return 0;
    }
    printf("YES\n");
    if(k<=m-1){
        printf("1\n");
        printf("%d R",k);
        return 0;
    }
    if(k<=2*(m-1)){
        printf("2\n");
        printf("%d R\n",m-1);
        printf("%d L",k-(m-1));
        return 0;
    }
    if(k<=4*m*n-2*m-3*n+1){
        k-=2*(m-1);
        int sum;
        if(m>1) sum=2+k/(4*m-3)*3;
        else sum=k;
        int q=k%(4*m-3);
        if(q>=1) sum++;
        if(q>1) sum++;
        q-=m;
        if(q>0){
            if(q/3>0) sum++;
            if(q%3>0) sum++;
        }
        q+=m;
        printf("%d\n",sum);
        if(m-1>0){
            printf("%d R\n",m-1);
            printf("%d L\n",m-1);
        }
        int cm=k/(4*m-3);
        for(int i=1;i<=cm;i++)
            if(m-1>0)printf("1 D\n%d R\n%d UDL\n",m-1,m-1);
            else printf("1 D\n");
        if(q==0) return 0;
        printf("1 D\n");
        q--;
        if(q<=0) return 0;
        printf("%d R\n",min(q,m-1));
        q-=m-1;
        if(q<=0) return 0;
        int yy=q/3;
        if(yy>0) printf("%d UDL\n",yy);
        int qq=q%3;
        if(qq==1) printf("1 U");
        if(qq==2) printf("1 UD");
        return 0;
    }
    if(m>1)printf("%d\n",(n-1)*3+3);
    else printf("%d\n",n);
    k-=2*(m-1);
    if(m-1>0){
        printf("%d R\n",m-1);
        printf("%d L\n",m-1);
    }
    for(int i=1;i<=n-1;i++)
        if(m>1)printf("1 D\n%d R\n%d UDL\n",m-1,m-1);
        else printf("1 D\n");
    k-=(4*m-3)*(n-1);
    printf("%d U",k);
    return 0;
}

ウカレタ蝶になって,一途な風に乗って

考场码风略凌乱,请见谅

CF #619 div.2的更多相关文章

  1. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

  2. CF #375 (Div. 2) D. bfs

    1.CF #375 (Div. 2)  D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...

  3. CF #374 (Div. 2) D. 贪心,优先队列或set

    1.CF #374 (Div. 2)   D. Maxim and Array 2.总结:按绝对值最小贪心下去即可 3.题意:对n个数进行+x或-x的k次操作,要使操作之后的n个数乘积最小. (1)优 ...

  4. CF #374 (Div. 2) C. Journey dp

    1.CF #374 (Div. 2)    C.  Journey 2.总结:好题,这一道题,WA,MLE,TLE,RE,各种姿势都来了一遍.. 3.题意:有向无环图,找出第1个点到第n个点的一条路径 ...

  5. CF #371 (Div. 2) C、map标记

    1.CF #371 (Div. 2)   C. Sonya and Queries  map应用,也可用trie 2.总结:一开始直接用数组遍历,果断T了一发 题意:t个数,奇变1,偶变0,然后与问的 ...

  6. CF #365 (Div. 2) D - Mishka and Interesting sum 离线树状数组

    题目链接:CF #365 (Div. 2) D - Mishka and Interesting sum 题意:给出n个数和m个询问,(1 ≤ n, m ≤ 1 000 000) ,问在每个区间里所有 ...

  7. CF #365 (Div. 2) D - Mishka and Interesting sum 离线树状数组(转)

    转载自:http://www.cnblogs.com/icode-girl/p/5744409.html 题目链接:CF #365 (Div. 2) D - Mishka and Interestin ...

  8. CF#138 div 1 A. Bracket Sequence

    [#138 div 1 A. Bracket Sequence] [原题] A. Bracket Sequence time limit per test 2 seconds memory limit ...

  9. CF 552(div 3) E Two Teams 线段树,模拟链表

    题目链接:http://codeforces.com/contest/1154/problem/E 题意:两个人轮流取最大值与旁边k个数,问最后这所有的数分别被谁给取走了 分析:看这道题一点思路都没有 ...

随机推荐

  1. Vue 常用三种传值方式

    Vue常用的三种传值方式: 父传子 子传父 非父子传值 引用官网一句话:父子组件的关系可以总结为 prop 向下传递,事件向上传递.父组件通过 prop 给子组件下发数据,子组件通过事件给父组件发送消 ...

  2. 十二、sed文本处理

    一.概述 1.sed 是一款流编辑工具,用来对文本进行过滤与替换工作,特别是当你想要对几十个配置文件做统计修改时,你会感受到 sed 的魅力!sed 通过输入读取文件内容,但一次仅读取一行内容进行某些 ...

  3. [python]Mongodb

    文档: http://api.mongodb.com/python/current/tutorial.html 安装: 官网直接下载安装, mac上brew安装的下载太慢, 打算手动安装 使用: 开启 ...

  4. HDU_3410_单调栈

    http://acm.hdu.edu.cn/showproblem.php?pid=3410 初探单调栈,从左往右,求l,从右往左,求r. #include<iostream> #incl ...

  5. 拖延症?贪玩?来试试"百万金币时间管理法"

    中午吃完饭就想休息? 一到假期就起不来? 总是想玩游戏? 究其原因是因为我们没有深刻意识到时间的价值. 这点在大气爱智慧的视频:懂这个道理,保证让你快速自律起来!拯救拖延症,更好的戒掉不良习惯中有讲到 ...

  6. python之字典遍历方法

    字典遍历分为三种: 遍历key 遍历value 遍历key-value key遍历: >>> person={','city':'BeiJing'} >>> for ...

  7. TestStand 基础知识[6]--Build-in Step Types (1)

    Step Types 有TestStand自带的,也有自定义的.本文先介绍自带的Step Types. 首先什么是Step Types ? 翻译过来就是步骤的类型,类似数据类型--数据有整型,字符串, ...

  8. 日志框架 log4j2 全解析

    概述 logging翻译为日志记录 那问题是什么是日志? 日志实际上是日记的一种,用于记录某个时间点发生了什么事情,比如大学老师的教学日志,工作日志等 为什么要记录日志? 在实际生活中记录日志主要为了 ...

  9. 实现理论上无tps上限的分布式压测(基于Jmeter+InfluxDB+Grafana+Spring Boot)

    JMeter自身带有Master-Slave压测框架,对于并发量不是很高的压力情况下(比如tps低于5000),该方案是可行的,并且使用起来非常方便,只要在配置文件或者命令行工具的参数做一些补充,即可 ...

  10. 微信支付v3版本NET 图片上传API

    最近在写特约服务商进件的由于微信官方没有DEMO,导致踩了很多坑,特把自己经验分享给大家. 注意几点: 1.上传图片签名不是把所有body内容都进行签名,只需签名计算的请求主体为meta的json串: ...