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& ...
随机推荐
- 信息收集之zoomeye
一.浏览器上使用api接口 1.https://api.zoomeye.org/user/login post传参:{"username" : "username&quo ...
- 2017ACM暑期多校联合训练 - Team 4 1004 HDU 6070 Dirt Ratio (线段树)
题目链接 Problem Description In ACM/ICPC contest, the ''Dirt Ratio'' of a team is calculated in the foll ...
- php常用表单验证类用法实例
<?php /** * 页面作用:常用表单验证类 * 作 者:欣然随风 * QQ:276624915 */ class class_post { //验证是否为指定长度的字母/数字组合 func ...
- 简单漂亮的php验证码函数
/* *说明:函数功能是生成验证码 * 参数说明:输入 长度,宽度,高度 */ function vcode($_code_length = , $_width = , $_height = ){ $ ...
- MySQL join 用法
select column1, column2 from TABLE1 join TABLE2 on 条件 # select * from table1 join table2; #两个表合成一个se ...
- thinkphp中的验证器
- flask基础之jijia2模板使用基础(二)
前言 在以前前后端不分离的时代,后台程序员往往又当爹又当妈,需要将前端程序员写的h5页面填充模板语言.而jijia2是一门十分强大的python的模板语言,是flask框架的核心模块之一.先简单介绍一 ...
- Elasticsearch5.0 安装问题集锦【转】
转自 Elasticsearch5.0 安装问题集锦 - 代码&优雅着&生活 - 博客园http://www.cnblogs.com/sloveling/p/elasticsearch ...
- Python多态、鸭子类型
一.多态 多态指的是一类事物有多种形态. 动物有多种形态:人,狗,猪 import abc class Animal(metaclass=abc.ABCMeta): #同一类事物:动物 @abc.ab ...
- angular项目中使用jquery的问题
1.使用npm命令往项目中添加jQuery. npm install jquery --save 2.在你想要用jQuery的组件中添加. import * as $ from "jquer ...