18年11月5日 NOIP模拟赛
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模拟赛的更多相关文章
- 18年10月31日 NOIP模拟赛
T1.exercise 题解 数据很小直接模拟 代码 #include<iostream> #include<cstdio> #include<cmath> #in ...
- 18年10月30日 NOIP模拟赛
T1 jkl 题解 显然每次都取a[i]的最大值/最小值,并更新a[i]即可 用数据结构维护这一操作..得分看常数 事实上用v[i]记录权值为i的个数,然后for乱搞就可以了... 其它乱搞做法能获得 ...
- 9月24日noip模拟赛解题报告
1.校门外的树(tree.c/cpp/pas 128M,1s) Description LSGJ扩建了,于是校门外有了一条长为L的路.路上种了一排的树,每相邻两棵树之间的距离为1,我们可以把马路看成一 ...
- NOIP2017年11月9日赛前模拟
最后一次NOIP模拟了····· 题目1:回文数字 Tom 最近在研究回文数字. 假设 s[i] 是长度为 i 的回文数个数(不含前导0),则对于给定的正整数 n 有:
- NOIP模拟赛 by hzwer
2015年10月04日NOIP模拟赛 by hzwer (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...
- 2016年11月27日 星期日 --出埃及记 Exodus 20:18
2016年11月27日 星期日 --出埃及记 Exodus 20:18 When the people saw the thunder and lightning and heard the trum ...
- 2016年11月2日 星期三 --出埃及记 Exodus 19:18
2016年11月2日 星期三 --出埃及记 Exodus 19:18 Mount Sinai was covered with smoke, because the LORD descended on ...
- 北京Uber优步司机奖励政策(11月23日~11月29日)
用户组:人民优步"关羽组"(适用于11月23日-11月29日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最 ...
- 北京Uber优步司机奖励政策(11月16日~11月22日)
用户组:人民优步“关羽组”(适用于11月16日-11月22日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/ ...
随机推荐
- Json递归解析实例
最近遇到包含多层的Json字符串解析的问题,查了一些帖子,不能很好解决.看了下帮助文档,用下面方法解决. 上代码 Maven 库 <!-- https://mvnrepository.com/a ...
- ASP.NET jQuery 事件里调用后台方法
利用js 调用后台写的方法 <script src="js/jquery-1.7.1.min.js"></script> <script> $( ...
- FacebookFriendAdderPro
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Fe ...
- GDC NEC单机自动化设置
GDC NEC 单机自动化设置 进入播放列表 进入设置,进入登陆,请选择维修员登陆,输入密码257910 选择“一般选项”中的“自动化” 在进入的新菜单中选择“设备”,添加一个新的名称,默认的 ...
- HTML列表(组标签)+div(布局标签)与span
一.列表 HTML中常见的列表有三种,分别是: 1.无序列表,是一组描述列表语义的组标签,列表中每个项之间没有先后顺序:如图: 1)组标签:组标签就是由多个标签组成的一个整体,它们之间共同存在:例如 ...
- Unity3d之MonoBehavior自带方法的执行顺序
首先贴一张图(从其他地方摘录的,不记得出处,如果有小伙伴知道可以评论留言) 看了以后脑子有个大概的概念,可还是一知半解的感觉(接触Unity也有2年之久,却从来没想过弄清楚心中这团迷雾,总是囫囵吞枣用 ...
- java:tag 自定义标签应用
一,tag类 1.1 TagMy标签类,格式化当前日期并输出 package com.dkt.tag; import java.io.IOException; import java.text.Sim ...
- 【canvas系列】canvas实现“ 简单的Amaziograph效果”--画对称图【强迫症福利】
标题很难引人入胜,先放个效果图好了 如果图片吸引不了你,那我觉得也就没啥看的了. demo链接: https://win7killer.github.io/demo_set/html_demo/can ...
- ComboBox Style
<SolidColorBrush x:Key="ComboBoxNormalBorderBrush" Color="#e3e9ef" /> < ...
- GitHub已将持续集成服务器Janky开源
GitHub已将Janky开源,这是他们构建在Jenkins之上的持续集成服务器,并在其中增加了聊天自动化工具Hubot. 除了一般的Jenkins功能之外,Janky还通过Hubot对功能进行了补充 ...