最近状态极差。。水题不想写,难题咬不动。。哎,CF的题那么简单,还搞崩了= =、真是巨菜无比。

Codeforces777A

题意:略。

思路:

构造出3!次变换,然后输出就好。

Code:

#include <bits/stdc++.h>
using namespace std; int a[6][4]={{1,2,3},{2,1,3},{2,3,1},{3,2,1},{3,1,2},{1,3,2}}; int main()
{
int n,x;
scanf("%d",&n);
scanf("%d",&x);
n%=6;
int ans=a[n][x];
ans--;
printf("%d\n",ans);
return 0;
}

Codeforces777B

题意:

比较一下,小的数字的那个人要打一下。求第二串的最少,第一串的最多。

思路:(弱弱觉得有点意思)

两个数组,先排下序.

(1)我要少一些,我从大的去匹配对方,而且先与对方大的去匹配最优,如果不行,最小的来匹配。

(2)我要多一些,那么我小的尽可能去贴小的,同理不行的话,我拿最大的过去

Code:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
char s1[1010],s2[1010];
int s[1010];
int m[1010];
int n; void solve1()
{
int k1=0,k2=0;
int t1=n-1,t2=n-1;
int ans1=0;
while(k1<=t1&&k2<=t2)
{
if(m[t2]>=s[t1])
{
t1--;
t2--;
}
else
{
t1--;
k2++;
ans1++;
}
}
printf("%d\n",ans1);
} void solve2()
{
int k1=0,k2=0;
int t1=n-1,t2=n-1;
int ans2=0;
while(k1<=t1&&k2<=t2) //小的贴小的,不行的话我最大的贴小的。
{
if(s[k1]<m[k2])
{
k1++;
k2++;
ans2++;
}
else
{
t1--;
k2++;
}
}
printf("%d\n",ans2);
} int main()
{
scanf("%d",&n);
scanf("%s%s",s1,s2);
for(int i=0;i<n;i++)
s[i]=s1[i]-'0';
for(int i=0;i<n;i++)
m[i]=s2[i]-'0';
sort(s,s+n);
sort(m,m+n);
solve1();
solve2();
return 0;
}
/*
4
1234
2345
*/

Codeforces777C:

就是直接搞就好了,对于每列可以尺取,也可以拿个临时变量作为当前最远位置,这里是预处理出一个数组存每个位置的最远距离。

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e6+10;
vector<int>xs[100010];
int num[100010];
int n,m; void solve()
{
for(int i=0;i<m;i++)
{
int tmp=-1;
int L;
for(int j=0;j<xs[i].size();j++)
{
int a=xs[i][j];
if(tmp==-1)
L=j+1;
else if(tmp>a)
{
num[L]=max(num[L],j);
L=j+1;
}
tmp=a;
}
num[L]=max(num[L],n);
} int tmp=-1;
for(int i=1;i<=n;i++)
{
num[i]=max(num[i],tmp);
tmp=max(num[i],tmp);
}
} int main()
{
int x,y;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
{
scanf("%d",&x);
xs[j].push_back(x);
}
solve();
int Q;
scanf("%d",&Q);
while(Q--)
{
scanf("%d%d",&x,&y);
if(num[x]>=y)
puts("Yes");
else
puts("No");
}
return 0;
}

Codeforces777D:

大水题。。

Code:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL; vector<char>xs[500010];
int n;
int len[500010];
char ss[500010];
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%s",ss);
int yy=strlen(ss);
for(int j=0;j<yy;j++)
xs[i].push_back(ss[j]);
}
int t1,t2;
len[n-1]=xs[n-1].size();
for(int i=n-2;i>=0;i--)
{
t1=0;t2=0;
bool flag=true;
if(len[i+1]==1)
{
len[i]=1;
continue;
}
while(t1<len[i+1]&&t2<xs[i].size())
{
if(xs[i+1][t1]==xs[i][t2])
{
t1++;
t2++;
}
else if(xs[i+1][t1]>xs[i][t2])
{
len[i]=xs[i].size();
flag=false;
break;
}
else
break;
}
if(flag)
len[i]=t2;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<len[i];j++)
cout<<xs[i][j];
puts("");
}
return 0;
}
/*
3
#sima
#simb
#sima
*/

Codeforces Round #401 (Div. 2)【A,B,C,D】的更多相关文章

  1. Codeforces Round #508 (Div. 2)【A,B,C,D】【实验室日常周赛训练】

    #include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f3f3f #define int long long ...

  2. Codeforces Round #343 (Div. 2)【A,B水题】

    A. Far Relative's Birthday Cake 题意: 求在同一行.同一列的巧克力对数. 分析: 水题~样例搞明白再下笔! 代码: #include<iostream> u ...

  3. Codeforces Round #553 (Div. 2) 【C. Problem for Nazar】

    题目大意: 一开始第一行是 1,第二行是2 4 ,第三行是3 5 7 9 ,类似这样下去,每一行的个数是上一行的个数,然后对这些点从第一个进行编号,问你从[l,r]区间数的和. 思路:分别求出奇数和偶 ...

  4. Codeforces Round #646 (Div. 2)【B. Subsequence Hate题解】

    具体思路已经在代码注释中给出,这里不再赘述. #include<iostream> #include<algorithm> using namespace std; int t ...

  5. Codeforces Round #401 (Div. 2) 离翻身就差2分钟

    Codeforces Round #401 (Div. 2) 很happy,现场榜很happy,完全将昨晚的不悦忘了.终判我校一片惨白,小董同学怒怼D\E,离AK就差一个C了,于是我AC了C题还剩35 ...

  6. Codeforces Round #443 (Div. 2) 【A、B、C、D】

    Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...

  7. Codeforces Round #436 (Div. 2)【A、B、C、D、E】

    Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...

  8. Codeforces Round #435 (Div. 2)【A、B、C、D】

    //在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...

  9. Codeforces Round #434 (Div. 2)【A、B、C、D】

    Codeforces Round #434 (Div. 2) codeforces 858A. k-rounding[水] 题意:已知n和k,求n的最小倍数x,要求x后缀至少有k个0. 题解:答案就是 ...

随机推荐

  1. SPFA的两个优化:SLF与LLL

    先举出个例题:洛谷P3371 [模板]单源最短路径 一眼扫去:最短路径. spfa不接受反驳... 附上代码: #include<iostream> #include<algorit ...

  2. FastJson 技术

    最近开始做淘宝的开放平台.阿里巴巴FastJson是一个Json处理工具包,包括“序列化”和“反序列化”两部分,它具备如下特征: 速度最快,测试表明,fastjson具有极快的性能,超越任其他的Jav ...

  3. graphics基础

  4. ssh_jar包选择

    1.struts2.3.29 + spring-framework-3.2.9.RELEASE +hibernate-distribution-3.6.10 * struts 所需jar 在:如下所示 ...

  5. javascript(7)

    js中基于对象==js面向对象 js中没有类class,但是它 JavaScript是一种面向(基于)对象的动态脚本语言,是一种基于对象和事件驱动并具有安全性能的脚本语言.它具有面向对象语言所特有的各 ...

  6. JS事件派发器EventEmitter

    原文地址:http://zhangyiheng.com/blog/articles/js_event_mitter.html 需求 随着Browser客户端JS越来越复杂,MVC(Client端)设计 ...

  7. http://www.cnblogs.com/henw/archive/2012/01/06/2314870.html

    C#多线程学习 之 线程池[ThreadPool]   在多线程的程序中,经常会出现两种情况: 一种情况:   应用程序中,线程把大部分的时间花费在等待状态,等待某个事件发生,然后才能给予响应     ...

  8. 机器学习:Colorization using Optimization

    今天介绍 Siggraph 2004 年的一篇文章: Colorization using Optimization,利用优化的方法对灰度图像进行着色,这里用到了非常经典的泊松方程以及稀疏矩阵的线性优 ...

  9. Python: scikit-image 图像的基本操作

    这个用例说明Python 的图像基本运算 import numpy as np from skimage import data import matplotlib.pyplot as plt cam ...

  10. storm相关技术

    There are two kinds of nodes on a Storm cluster: the master node and the worker nodes. 有两种节点,主节点和wor ...