Test20171009 考试总结 NOIP模拟赛
题目难度合适,区分度适中,但是本人水平不佳,没有拿到满意的分数。
T1(matrix)
一种比较容易想到的想法是枚举起点求出最长全1串做预处理,这是O(n^2)的。
接着枚举列起点,列终点,通过后缀和维护矩形的高。这也是O(n^2)的。
实现的细节看代码:
#include<cstdio>
#include<cstdlib>
#include<cstring> #define max(a,b) (((a)>(b))?(a):(b)) const int maxn = ; int suf[maxn];//houzhuihe
int mat[maxn][maxn];//matrix
int len[maxn][maxn];//from some number ,the longest number int n,m; void read(){
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
scanf("%1d",&mat[i][j]);
for(int i=;i<=n;i++)
for(int j=m;j>=;j--)
len[i][j] = (mat[i][j]==?len[i][j+]+:);
} void work(){
int ans = ;
for(int i=;i<=m;i++){
for(int j=;j<=;j++)suf[j]=;
for(int j=;j<=n;j++) suf[len[j][i]]++;
for(int j=;j>=;j--) suf[j] = suf[j+]+suf[j];
for(int j=;j<=;j++) ans = max(ans,j*suf[j]);
}
printf("%d",ans);
} int main(){
freopen("matrix.in","r",stdin);
freopen("matrix.out","w",stdout);
read();work();return ;
}
T2(present)
这道题是一道完全背包恰好塞满的判断。对于希望达到的w,取单个价值最低的p。令剩下的构成费用x,x+kp=w.取最小的x即可。建图跑最短路。
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<algorithm>
using namespace std; struct edge{
int to,w;
};
bool operator <(edge a,edge b){return a.w<b.w;} int n,m,num,mn;
int p[],a[];
int dist[];
vector <edge> g[]; void read(){
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++) scanf("%d",&p[i]);
for(int j=;j<=m;j++) scanf("%d",&a[j]);
sort(p+,p+n+);
mn = p[];
} int vis[];
void spfa()
{
memset(dist,0x7f,sizeof(dist));
queue<int> q;
q.push();
dist[]=;vis[]=;
while(!q.empty()){
int x=q.front();q.pop();
vis[x]=;
for(int i=;i<=n;i++){
if(dist[(x+p[i])%mn]>dist[x]+p[i]){
dist[(x+p[i])%mn]=dist[x]+p[i];
if(!vis[(x+p[i])%mn]){
q.push((x+p[i])%mn);
vis[(x+p[i])%mn]=;
}
}
}
}
}
void work(){
spfa();
int ans=;
for(int i=;i<=m;i++){
if(dist[a[i]%mn]<=a[i])ans++;
}
printf("%d",ans);
} int main(){
freopen("present.in","r",stdin);
freopen("present.out","w",stdout);
read();
work();
return ;
}
T3(mahjong)
搜索简单题,期望得分100实际得分0.。。
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#pragma GCC optimize(2)
using namespace std; int tb[],flag,what;
int pd_double[]={,,,,,,,,,,,,,};
int ans[],num; int str_num(char ch[]){
switch(ch[]){
case 'm':{return ch[]-'';}
case 's':{return ch[]-''+;}
case 'p':{return ch[]-''+;}
case 'c':{return ch[]-''+;}
}
}
void read(){
memset(tb,,sizeof(tb));
memset(ans,,sizeof(ans));
for(int i=;i<=;i++){
char ch[]; scanf("%s",ch);
tb[str_num(ch)]++;
}
} int contry_no_double(){
int etnum=;
for(int i=;i<=;i++){
if(!tb[pd_double[i]]){
if(flag)return ; else{flag = ;what = pd_double[i];}
}
etnum+=tb[pd_double[i]];
}
if(flag == &&etnum==){ans[what] = ;return ;}
else{
printf("13 1m 9m 1s 9s 1p 9p 1c 2c 3c 4c 5c 6c 7c\n");
return ;
}
}
void seven_double(){
int dnum = ,rec;
for(int i=;i<=;i++){
if(tb[i] > )return;
if(tb[i] == )dnum++;
if(tb[i] == )rec = i;
}
if(dnum == )ans[rec]=;
} int dd[],nd;
void dfs(int dep,int last,int deal){
while(!tb[last]&&last<=)last++;
if(deal == ){
if(flag == )
if(dd[]==dd[]&&nd==){
ans[what]=;return;
}
if(flag==){
if(nd==){ans[dd[]]=;return;}
if(nd==){
sort(dd+,dd+);
if(dd[]==dd[]&&dd[]==dd[]){ans[dd[]]=;ans[dd[]]=;}
if(dd[]-dd[]==&&dd[]==dd[]&&dd[]/!=){ans[dd[]-]=;ans[dd[]+]=;}
if(dd[]==dd[]&&dd[]-dd[]==&&dd[]/!=){ans[dd[]+]=;ans[dd[]-]=;}
}
return;
}
}
if(tb[last]&&tb[last+]&&tb[last+]&&last/!=){
tb[last]--;tb[last+]--;tb[last+]--;
dfs(dep+,last,deal+);
tb[last]++;tb[last+]++;tb[last+]++;
}
if(tb[last]>=){
tb[last]-=;
dfs(dep+,last,deal+);
tb[last]+=;
}
if(nd<){
int cc[];for(int i=;i<=nd;i++)cc[i]=dd[i];
cc[nd+]=last;
sort(cc+,cc+nd+);
int fff = ;
if(nd<)fff=;
if(!fff){
tb[last]--;dd[++nd]=last;
dfs(dep+,last,deal+);
tb[last]++;nd--;
}
}
if(tb[last]==&&(!flag)){
tb[last]-=;flag = ;what = last;
dfs(dep+,last+,deal+);
flag = ;tb[last]+=;
}
if(last%==||last%==||last/==)return;
if((bool)tb[last]+(bool)tb[last+]+(bool)tb[last+]== && (!flag)){
if(!tb[last+]){
tb[last]--;tb[last+]--;flag = ;what=last+;
dfs(dep+,last,deal+);
tb[last]++;tb[last+]++;flag = ;
}
if(!tb[last+]){
tb[last]--;tb[last+]--;flag = ;what = last+;
dfs(dep+,last,deal+);
tb[last]++;tb[last+]++;flag = ;
}
}
} void work(){
flag = ;num=;
int fg = contry_no_double();
if(fg)return;
flag = ;
seven_double();
dfs(,,);
int a1=;
for(int i=;i<=;i++){
if(i%==)continue;
if(ans[i]&&tb[i]==)ans[i]=;
if(ans[i])a1++;
}
if(a1==){puts("Nooten");}
else{
printf("%d ",a1);
for(int i=;i<=;i++) if(ans[i])printf("%dm ",i);
for(int i=;i<=;i++) if(ans[+i])printf("%ds ",i);
for(int i=;i<=;i++) if(ans[+i])printf("%dp ",i);
for(int i=;i<=;i++) if(ans[+i])printf("%dc ",i);
puts("");
}
} int main(){
freopen("mahjong.in","r",stdin);
freopen("mahjong.out","w",stdout);
int t; scanf("%d",&t);
while(t--){read();work();}
return ;
}
Test20171009 考试总结 NOIP模拟赛的更多相关文章
- 10.17 NOIP模拟赛
目录 2018.10.17 NOIP模拟赛 A 咒语curse B 神光light(二分 DP) C 迷宫maze(次短路) 考试代码 B 2018.10.17 NOIP模拟赛 时间:1h15min( ...
- 10.16 NOIP模拟赛
目录 2018.10.16 NOIP模拟赛 A 购物shop B 期望exp(DP 期望 按位计算) C 魔法迷宫maze(状压 暴力) 考试代码 C 2018.10.16 NOIP模拟赛 时间:2h ...
- NOIP模拟赛-2018.11.7
NOIP模拟赛 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 编译之前另存一份,听说如果敲 ...
- NOIP模拟赛-2018.11.6
NOIP模拟赛 今天想着反正高一高二都要考试,那么干脆跟着高二考吧,因为高二的比赛更有技术含量(我自己带的键盘放在这里). 今天考了一套英文题?发现阅读理解还是有一些困难的. T1:有$n$个点,$m ...
- NOIP模拟赛-2018.11.5
NOIP模拟赛 好像最近每天都会有模拟赛了.今天从高二逃考试跑到高一机房,然而高一也要考试,这回好像没有拒绝的理由了. 今天的模拟赛好像很有技术含量的感觉. T1:xgy断句. 好诡异的题目,首先给出 ...
- Nescafe #29 NOIP模拟赛
Nescafe #29 NOIP模拟赛 不知道这种题发出来算不算侵权...毕竟有的题在$bz$上是权限题,但是在$vijos$似乎又有原题...如果这算是侵权的话请联系我,我会尽快删除,谢谢~ 今天开 ...
- 【HHHOJ】NOIP模拟赛 捌 解题报告
点此进入比赛 得分: \(30+30+70=130\)(弱爆了) 排名: \(Rank\ 22\) \(Rating\):\(-31\) \(T1\):[HHHOJ260]「NOIP模拟赛 捌」Dig ...
- NOIP模拟赛20161022
NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...
- contesthunter暑假NOIP模拟赛第一场题解
contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...
随机推荐
- 源自人脑的神奇算法 -- 读《How to make your own neural network》有感
最近读到了一本很好的关于机器学习-深度学习的书值得推荐下并特意做了这个学习总结. 为什么推荐 在我认为好书(计算机类)的评判有几个标准: 试图以通俗的语言阐述,并在引入任何新概念的时候都讲述来龙去脉, ...
- 【洛谷 P3299】 [SDOI2013]保护出题人 (凸包,三分,斜率优化)
题目链接 易得第\(i\)关的最小攻击力为\(\max_{j=1}^i\frac{sum[i]-sum[j-1]}{x+d*(i-j)}\) 十分像一个斜率式,于是看作一个点\(P(x+d*i,sum ...
- eclipse运行Android项目出现“The connection to adb is down, and a severe error has occured. You must restart adb and Eclipse. ”
重启eclipse之后仍然出现同样错误,此时可以尝试一下方法: cmd打开命令窗口: 之后重启eclipse,基本可以解决问题!
- Spring Tool Suite 配置和使用
Spring Tool Suite使用 1.下载地址: http://spring.io/tools 2.配置字符编码:UTF-8 默认的编码是ISO-8859-1的西欧文字编 1.windows-- ...
- Big O
评价一个计算机算法的效率时用到的方法我们称之为Big O(Order of [大约是]). 有序二分查找算法: 比如我们通过二分查找算法查找容器里的10个数据. 那么,我们需要查找一个数据时正常应该是 ...
- 【swupdate文档 五】从可信的来源更新镜像
从可信的来源更新镜像 现在越来越重要的是,设备不仅要能安全地进行更新操作, 而且要能够验证发送的图像是否来自一个已知的源, 并且没有嵌入恶意软件. 为了实现这个目标,SWUpdate必须验证传入的镜像 ...
- HZ与Jiffies
2.4 内核定时器 内核中许多部分的工作都高度依赖于时间信息.Linux内核利用硬件提供的不同的定时器以支持忙等待或睡眠等待等时间相关的服务.忙等待时,CPU 会不断运转.但是睡眠等待时,进程将放弃C ...
- C++——stoi函数
版权声明:本文系原创,转载请声明出处. 1. 函数原型 , ); , ); 2. 参数说明 str String object with the representation of an integr ...
- Linux中常用命令 <一>
本笔记中记录的命令来源于 <Linux C 编程实战> ------------------------------------------------------------------ ...
- UTF-8和GB2312互转的最简单快捷的方法
一.如果你想把utf-8转为GB2312 1.用记事本打开源码,把<meta http-equiv="Content-Type" content="text/htm ...