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. 题解:答案就是 ...
随机推荐
- react-navigation遇到的坑
关于goBack返回指定页面 react-navigation是提供了goBack()到指定页面的方法的,那就是在goBack()中添加一个参数,但当你使用goBack('Main')的时候,你会发现 ...
- pyinstaller使用
python pyinstaller.py [-Fw] ???.py -F 将相关配件(dll.oxc)合成到单个exe文件 -w exe启动时不打开console窗口
- 2016WWDC详解
今年苹果WWDC 2016上把所有系统都更新了个遍,watchOS.tvOS.macOS 和 iOS 都或多或少带来了新功能. 本文的主角是更新最多的 iOS 10,第一时间在一部 iPhone 6s ...
- chunkhash笔记
假设有main1.main2两个入口文件,main引入chunk1.chunk2,main2引入chunk1 改变chunk2 main1的chunkhash改变,main2不发生改变 main再引入 ...
- HDU 1032 The 3n + 1 problem (这个题必须写博客)
The 3n + 1 problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- Dictionary and KeyValuePair关系
简单一句话: Dictionary 是 由 KeyValuePair结构 组成的集合 The Dictionary<TKey, TValue>.Enumerator.Current pro ...
- zabbix增加服务器tcp监控
zabbix server web界面,需要导入 tcp 监控模板 操作步骤: Configuration --> Templates --> Import ,选择 本地的 zb ...
- Java里的阻塞队列
JDK7提供了7个阻塞队列,如下: ArrayBlockingQueue : 一个数组结构组成的有界阻塞队列. LinkedBlockingQueue : 一个由链表结构组成的有界阻塞队列 . Pr ...
- python- 双层装饰器 字符串格式化 python模块 递归 生成器 迭代器 序列化
1.双层装饰器 #!/usr/bin/env python3 # -*- coding: utf-8 -*- # author:zml LOGIN_INFO = False IS_ADMIN = Fa ...
- Listen 82
Doc Calls Deconditioning a Condition Doctors know a lot about prescribing medications. "Take tw ...