T1

题解

对于k=100的情况,贪心

对于100%的数据

可以发现,当前的决策只对后面的开采有影响,且剩余耐久度与之后的开采收益成正比,如果倒着考虑这个问题,得出i-n的星球1点耐久度所能获得的最大收益,从后往前dp,得出最大值最后乘w就是答案

代码

#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100001;
int n,w,t[maxn],a[maxn];
double k,c,ans;
int main()
{
//freopen("exploit.in","r",stdin);
//freopen("exploit.out","w",stdout);
scanf("%d%lf%lf%d",&n,&k,&c,&w);
k=1-0.01*k;c=1+0.01*c;
for(int i=1;i<=n;i++)scanf("%d%d",&t[i],&a[i]);
for(int i=n;i;i--)
if(t[i]==1)
ans=max(ans,ans*k+a[i]);
else
ans=max(ans,ans*c-a[i]);
printf("%.2lf\n",ans*w);
}

T2

题解

从前往后推出每个人最少/最多有几个和第一个人相同的勋章

然后看最后一个最少是否是0即可

代码

#include<bits/stdc++.h>

inline int read()
{
int x = 0,t = 1; char ch = getchar();
while(ch < '0' || ch > '9'){if(ch == '-') t = -1; ch = getchar();}
while(ch >= '0' && ch <= '9'){x = x*10+ch-'0'; ch = getchar();}
return x*t;
} const int MAXN = 20010;
int n;
int num[MAXN];
int L,R,mid;
int dp[MAXN],gun[MAXN]; inline void init()
{
n = read();
for(int i=1;i<=n;i++)
num[i] = read();
for(int i=1;i<n;i++)
L=std::max(L,num[i]+num[i+1]); L=std::max(L,num[n]+num[1]),R=0x7ffffff;
} inline void DP()
{
while(L<R)
{
mid=(L+R)>>1;
dp[1]=gun[1]=num[1]; for(int i=2;i<=n;i++)
dp[i]=std::min(num[i],num[1]-gun[i-1]), gun[i]=std::max(0,num[i]-(mid-num[i-1]-(num[1]-dp[i-1]))); if(gun[n]==0) R=mid;
else L=mid+1;
}
std::cout << L;
} int main(void)
{
std::ios_base::sync_with_stdio(false); init();
DP(); return 0;
}

T3

题解

30%: O(n ^ 2 * m)暴力判断。

100%: 很显然答案的可能性最多只有n 种,所以我们将所有人的答案按字典序排序后枚举

将每个人的答案作为正确答案来进行判断。由于是判断题,若当前人的答案为正确答

案则零分者的答案也就确定了,那么只需统计出这两种答案的人数判断是否满足题意

即可。这一步使用字符串哈希即可解决。

另外要注意p = 0 和p = q = 0 的情况。

代码

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std; const int N = 3e4 + 2, M = 5e2 + 2, sed = 31, SED = 131, mod = 70177, MOD = 92311;
int n, m, p, q, ans, hash[N], HASH[N];
int top, info[mod], nxt[N * 2], fet[N * 2], cnt[N * 2];
struct node {
char s[M];
inline bool operator < (const node &b) const {
return strcmp(s, b.s) < 0;
}
} a[N]; inline void Insert(const int &x, const int &y) {
for (int k = info[x]; k; k = nxt[k])
if (fet[k] == y) {
++cnt[k]; return ;
}
nxt[++top] = info[x]; info[x] = top;
fet[top] = y; cnt[top] = 1;
return ;
} inline int Query(const int &x, const int &y) {
for (int k = info[x]; k; k = nxt[k])
if (fet[k] == y) return cnt[k];
return 0;
} inline void Solve1() {
int tmp, TMP; ans = -1;
for (int i = 0; i < n; ++i) {
tmp = TMP = 0;
for (int j = 0; j < m; ++j) {
tmp = (tmp * sed + (a[i].s[j] == 'N')) % mod;
TMP = (TMP * SED + (a[i].s[j] == 'N')) % MOD;
}
hash[i] = tmp, HASH[i] = TMP;
Insert(tmp, TMP);
}
for (int i = 0; i < n; ++i)
if (Query(hash[i], HASH[i]) == p) {
tmp = TMP = 0;
for (int j = 0; j < m; ++j) {
tmp = (tmp * sed + (a[i].s[j] == 'Y')) % mod;
TMP = (TMP * SED + (a[i].s[j] == 'Y')) % MOD;
}
if (Query(tmp, TMP) == q) {
ans = i; break;
}
}
if (ans != -1) printf("%s\n", a[ans].s);
else puts("-1");
return ;
} char cur[M];
inline void Solve2() {
int tmp, TMP; ans = -1;
for (int i = 0; i < n; ++i) {
tmp = TMP = 0;
for (int j = 0; j < m; ++j) {
tmp = (tmp * sed + (a[i].s[j] == 'N')) % mod;
TMP = (TMP * SED + (a[i].s[j] == 'N')) % MOD;
}
hash[i] = tmp, HASH[i] = TMP;
Insert(tmp, TMP);
}
for (int i = n - 1; i >= 0; --i)
if (Query(hash[i], HASH[i]) == q) {
tmp = TMP = 0;
for (int j = 0; j < m; ++j) {
tmp = (tmp * sed + (a[i].s[j] == 'Y')) % mod;
TMP = (TMP * SED + (a[i].s[j] == 'Y')) % MOD;
}
if (Query(tmp, TMP) == p) {
ans = i; break;
}
}
if (ans != -1) {
for (int i = 0; i < m; ++i)
cur[i] = a[ans].s[i] == 'N' ? 'Y' : 'N';
printf("%s\n", cur);
}
else puts("-1");
return ;
} void Solve3() {
int tmp, TMP;
for (int i = 0; i < n; ++i) {
tmp = TMP = 0;
for (int j = 0; j < m; ++j) {
tmp = (tmp * sed + (a[i].s[j] == 'N')) % mod;
TMP = (TMP * SED + (a[i].s[j] == 'N')) % MOD;
}
Insert(tmp, TMP);
tmp = TMP = 0;
for (int j = 0; j < m; ++j) {
tmp = (tmp * sed + (a[i].s[j] == 'Y')) % mod;
TMP = (TMP * SED + (a[i].s[j] == 'Y')) % MOD;
}
Insert(tmp, TMP);
}
bool flag = true;
for (int i = 0; i < m; ++i) cur[i] = 'N';
do {
tmp = TMP = 0;
for (int j = 0; j < m; ++j) {
tmp = (tmp * sed + (cur[j] == 'N')) % mod;
TMP = (TMP * SED + (cur[j] == 'N')) % MOD;
}
if (Query(tmp, TMP) == 0) {
flag = true; break;
}
flag = false;
for (int j = m - 1; j >= 0; --j)
if (cur[j] == 'Y') cur[j] = 'N';
else {
cur[j] = 'Y'; flag = true; break;
}
} while (flag);
if (flag) printf("%s\n", cur);
else puts("-1");
return ;
} int main() {
//freopen("answer.in", "r", stdin);
//freopen("answer.out", "w", stdout);
scanf("%d%d%d%d", &n, &m, &p, &q);
for (int i = 0; i < n; ++i) scanf("%s", a[i].s);
sort(a, a + n);
if (p) Solve1();
else if (q) Solve2();
else Solve3();
fclose(stdin); fclose(stdout);
return 0;
}

18年11月5日 NOIP模拟赛的更多相关文章

  1. 18年10月31日 NOIP模拟赛

    T1.exercise 题解 数据很小直接模拟 代码 #include<iostream> #include<cstdio> #include<cmath> #in ...

  2. 18年10月30日 NOIP模拟赛

    T1 jkl 题解 显然每次都取a[i]的最大值/最小值,并更新a[i]即可 用数据结构维护这一操作..得分看常数 事实上用v[i]记录权值为i的个数,然后for乱搞就可以了... 其它乱搞做法能获得 ...

  3. 9月24日noip模拟赛解题报告

    1.校门外的树(tree.c/cpp/pas 128M,1s) Description LSGJ扩建了,于是校门外有了一条长为L的路.路上种了一排的树,每相邻两棵树之间的距离为1,我们可以把马路看成一 ...

  4. NOIP2017年11月9日赛前模拟

    最后一次NOIP模拟了····· 题目1:回文数字 Tom 最近在研究回文数字. 假设 s[i] 是长度为 i 的回文数个数(不含前导0),则对于给定的正整数 n 有:

  5. NOIP模拟赛 by hzwer

    2015年10月04日NOIP模拟赛 by hzwer    (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...

  6. 2016年11月27日 星期日 --出埃及记 Exodus 20:18

    2016年11月27日 星期日 --出埃及记 Exodus 20:18 When the people saw the thunder and lightning and heard the trum ...

  7. 2016年11月2日 星期三 --出埃及记 Exodus 19:18

    2016年11月2日 星期三 --出埃及记 Exodus 19:18 Mount Sinai was covered with smoke, because the LORD descended on ...

  8. 北京Uber优步司机奖励政策(11月23日~11月29日)

    用户组:人民优步"关羽组"(适用于11月23日-11月29日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最 ...

  9. 北京Uber优步司机奖励政策(11月16日~11月22日)

    用户组:人民优步“关羽组”(适用于11月16日-11月22日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/ ...

随机推荐

  1. Activiti - 设置会签

    前些天在群里聊工作流和Activiti,群里有人分享了自己的工作流引擎开源项目,大伙纷纷问这问那(比如为什么突然自己搞个process engine.有没有eclipse plugin.能不能绘制流程 ...

  2. SPA应用部署时首屏启动慢问题解决方案

    SPA应用部署时首屏启动慢问题解决方案 使用vuejs开发的单页应用,打包部署上线后,发现首屏启动时间达到了惊人的10s左右,于是开始优化,目前使用到的总结如下: 巧用webpack插件 1.抽取cs ...

  3. 【转】JUC下面线程池介绍

    介绍new Thread的弊端及Java四种线程池的使用,对Android同样适用.本文是基础篇,后面会分享下线程池一些高级功能. 1.new Thread的弊端执行一个异步任务你还只是如下new T ...

  4. CSS reset的审视

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=758 一.CSS re ...

  5. flex自适应宽度显示省略号

    text-overflow:ellipsis文本溢出显示省略号,一般的搭配用法如下: div{ text-overflow:ellipsis; overflow:hidden; white-space ...

  6. pom.xml配置文件内容记录

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  7. parseInt OR Number进行数字的转换

    在js中,字符串转为数字类型是比较常见的,平时用的比较多的是parseFloat和parseInt这两个方法.当然,除了这个方法之外还有一个Number:都是转为数字类型,有什么差别? 可以简单的说N ...

  8. js面向对象设计之class中一些坑和技巧

    this的指向 super 类工厂,类中定义方法名时,可以使用字符串,这就可以创建工厂函数(类似模板类) Generator 函数 静态属性和私有属性.私有方法 new.target

  9. 阿里react整合库dva demo分析 [转]

    同,也是工作中需要,用到 dva ,  也找了些文章参考知识点. 更多:http://www.cnblogs.com/heyuqing/p/6844098.html 以下内容为摘出  mark 接着踩 ...

  10. OpenGL学习--08--基本渲染(灯光)

    1.tutorial08.cpp // Include standard headers #include <stdio.h> #include <stdlib.h> #inc ...