Codeforces Round #401 (Div. 2)【A,B,C,D】
最近状态极差。。水题不想写,难题咬不动。。哎,CF的题那么简单,还搞崩了= =、真是巨菜无比。
题意:略。
思路:
构造出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;
}
题意:
比较一下,小的数字的那个人要打一下。求第二串的最少,第一串的最多。
思路:(弱弱觉得有点意思)
两个数组,先排下序.
(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
*/
就是直接搞就好了,对于每列可以尺取,也可以拿个临时变量作为当前最远位置,这里是预处理出一个数组存每个位置的最远距离。
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;
}
大水题。。
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】的更多相关文章
- Codeforces Round #508 (Div. 2)【A,B,C,D】【实验室日常周赛训练】
#include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f3f3f #define int long long ...
- Codeforces Round #343 (Div. 2)【A,B水题】
A. Far Relative's Birthday Cake 题意: 求在同一行.同一列的巧克力对数. 分析: 水题~样例搞明白再下笔! 代码: #include<iostream> u ...
- Codeforces Round #553 (Div. 2) 【C. Problem for Nazar】
题目大意: 一开始第一行是 1,第二行是2 4 ,第三行是3 5 7 9 ,类似这样下去,每一行的个数是上一行的个数,然后对这些点从第一个进行编号,问你从[l,r]区间数的和. 思路:分别求出奇数和偶 ...
- Codeforces Round #646 (Div. 2)【B. Subsequence Hate题解】
具体思路已经在代码注释中给出,这里不再赘述. #include<iostream> #include<algorithm> using namespace std; int t ...
- Codeforces Round #401 (Div. 2) 离翻身就差2分钟
Codeforces Round #401 (Div. 2) 很happy,现场榜很happy,完全将昨晚的不悦忘了.终判我校一片惨白,小董同学怒怼D\E,离AK就差一个C了,于是我AC了C题还剩35 ...
- Codeforces Round #443 (Div. 2) 【A、B、C、D】
Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...
- Codeforces Round #436 (Div. 2)【A、B、C、D、E】
Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...
- Codeforces Round #435 (Div. 2)【A、B、C、D】
//在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...
- 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. 题解:答案就是 ...
随机推荐
- js实现随机选取[10,100)中的10个整数,存入一个数组,并排序。 另考虑(10,100]和[10,100]两种情况。
1.js实现随机选取[10,100)中的10个整数,存入一个数组,并排序. <!DOCTYPE html> <html lang="en"> <hea ...
- 【题解】[JSOI2008]最大数
[题解][P1198 JSOI2008]最大数 正难则反,意想不到. 这道题是动态让你维护一个数列,已经在数列里面的数据不做改变,每次在最后加上一个数,强制在线. 既然正着做很难,考虑如果时间倒流,不 ...
- VirtualBox创建VM结果ProcessorType是空的
用WMI来查询CPU的频率,一直没问题: "Select MaxClockSpeed From Win32_Processor Where ProcessorType = 3" 结 ...
- Android 进程增加存活率
引用 : http://geek.csdn.net/news/detail/68515
- iOS开发的10个奇袭
1.关于关键字volatile 一个定义为volatile的变量是说这变量可能会被意想不到地改变,这样,编译器就不会去假设这个变量的值了.精确地说就是,优化器在用到这个变量时必须每次都小心地重新读取这 ...
- SVG圆盘时钟动画
在线演示 本地下载
- Zeppelin- Linux下安装Zeppelin
前期部署: 下载,解压,配置PATH环境(编辑/etc/profile文件,记得source一下该文件) zepplin配置参考文档:https://zeppelin.apache.org/docs/ ...
- T60
The smooth contour of the sculpture is wonderful.Her commitment to a great cause degenerated from a ...
- codeforces 705B B. Spider Man(组合游戏)
题目链接: B. Spider Man time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- android自定义控件(二) 入门,继承View
转载请注明地址:http://blog.csdn.net/ethan_xue/article/details/7313788 ps: 可根据apidemo里LableView,list4,list6学 ...