每天一套题打卡|河南省第十一届ACM/ICPC
A 计划日
题意:已知李明在YYYY年MM月DD日星期W订了学习计划,现在想看看李明N天后的完成情况和个人总结,你能告诉我那天的日期和星期几吗?

模拟日期计算;
计算星期可以用基姆拉尔森公式
//中国的星期 结果要+1
int Day(int y,int m,int d)
{
if(m==1 || m==2) m+=12,y-=1;
return (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7;
}
AC代码
#include<bits/stdc++.h>
using namespace std;
int t;
bool isLeap(int year){
if(year %4 == 0 && year%100!=0 || year%400== 0){
return true;
}
return false;
}
int main(){
cin>>t;
while(t--){
int year,ta,tb,tc,td,w,n,month,day;
scanf("%4d%1d%1d%1d%1d %d %d",&year,&ta,&tb,&tc,&td,&w,&n);
month = ta*10 + tb;
day = tc*10 + td;
if(w==7) w=0;
for(int i=1;i<=n;i++){
if(month == 12){
if(day==31){
year++;
month = 1;
day = 1;
}else{
day++;
}
}else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10){
if(day == 31){
month++;
day = 1;
}else{
day++;
}
}else if(month == 4 || month == 6 || month == 9 || month == 11){
if(day == 30){
month++;
day = 1;
}else{
day++;
}
}else if(month == 2){
if(isLeap(year)){
if(day == 29){
month++;
day = 1;
}else{
day++;
}
}else{
if(day == 28){
month++;
day = 1;
}else{
day++;
}
}
}
w = (w+1)%7;
}
printf("%d",year);
if(month<10){
printf("0%d",month);
}else{
printf("%d",month);
}
if(day<10){
printf("0%d ",day);
}else{
printf("%d ",day);
}
if(w==0) w = 7;
printf("%d\n",w);
}
return 0;
}
B 治安管理
题意:YYH大型活动将在[S,F)这段时间举行,现要求活动期间任何时刻巡逻的警察人数不少于M人。公安机关将有N名警察在维护活动的安全,每人巡逻时间为[ai,bi)。请你检查目前的值班安排,是否符合要求。若满足要求,输出YES,并输出某个时刻同时巡逻的最多人数;若不满足要求,输出NO,并输出某个时刻同时巡逻的最少人数。

暴力可以过;数据如果再复杂点,可以用差分求解区间问题。
AC代码
#include<bits/stdc++.h>
using namespace std;
int t;
const int maxn = 1e6+5;
int n,m,s,f;
int p[maxn];
int q[maxn];
int a[maxn];
int main(){
cin>>t;
while(t--){
memset(a,0,sizeof(a));
memset(p,0,sizeof(p));
memset(q,0,sizeof(q));
cin>>n>>m>>s>>f;
for(int i=1;i<=n;i++) cin>>p[i];
for(int i=1;i<=n;i++) cin>>q[i];
for(int i=1;i<=n;i++){
for(int j=p[i];j<q[i];j++){
a[j]++;
}
}
int mint = 0x3f3f3f3f;
int maxt = 0;
for(int i=s;i<f;i++){
if(mint >= a[i]) mint = a[i];
if(maxt <= a[i]) maxt = a[i];
}
if(mint == 0x3f3f3f3f) mint = 0;
if(mint<m)cout<<"NO "<<mint<<endl;
else cout<<"YES "<<maxt<<endl;
}
return 0;
}
C 山区修路
最近,HB省决定修一条从YC市通往SNJ风景区的高速公路。经过勘测分析,途中需要经过高度分别为H1,H2,……,Hn的N个山区。由于高低不平,除正常的修路开支外,每段还要多出高度差|Hi - Hi-1|*X万元的斜坡费用。Dr. Kong 决定通过填高一些区域的高度来降低总的费用。当然填高也是需要一些费用的。每填高Y单位,需要付出Y2万元费用。
你能否帮Dr. Kong做出一个规划,通过部分填高工程改造,使得总的费用降下来。

思路:线性dp,开始想用一维dp,发现一维没法做啊,前后两个山区都影响当前状态。应该用二维dp[i][j] 表示第i个山区在高度为j时的最小费用。
D 求XF+闭包
题意:前面大段都不用看
已知 F 是关系模式R(U)上的函数依赖集,利用Armstrong公理系统可以推导出更多的函数依赖。设X是属性集U={ A1,A2, ……, An} 的子集, 定义X关于F的闭包XF+
XF+={ Ai | 若X->Ai可以通过Armstrong公理导出}
对于给定的U , F ,X, 请求出XF+
意思就是:若X包含S,就将T加入X

思路:我是用字符串string直接做的,string.find()来查找
AC代码,南阳oj过不了,郑轻可以过,有时间再补题吧
#include<bits/stdc++.h>
using namespace std;
int t;
set<char> se;
int main(){
cin>>t;
while(t--){
int n,m,k;
cin>>n>>m>>k;
string u,x;
cin>>u;
cin>>x;
for(int i=1;i<=k;i++){
string s;
string t;
cin>>s;
cin>>t;
bool flag = true;
int len = s.length();
for(int j=0;j<len;j++){
if(x.find(s[j]) == string::npos){
flag = false;
break;
}
}
int len2 = t.length();
if(flag){
x.insert(x.length(),t);
// cout<<x<<endl;
}
}
for(int i=0;i<x.length();i++){
se.insert(x[i]);
}
set<char>::iterator it = se.begin();
while(it!=se.end()){
cout<<*it;
it++;
}
cout<<endl;
se.clear();
}
return 0;
}
E 物流配送
http://nyoj.top/web/contest/problem/cid/103/num/E
听说是最小费用最大流
但是我没做过题,想学的时候再补。
F Gene mutation
http://nyoj.top/web/contest/problem/cid/103/num/F
一道简单英文题
思路1:从X数组出发 枚举起点,看看x[i] - y[1]的长度下,x数组中是否都包含Y[j] + x[i] - y[1]
思路2:从Y数组出发,枚举加减的数量,在X中查找,如果存在Y的每一个元素,则记为一种方案。
我用思路2做的没过,有时间再用思路1做
G Checkpoints
Chinese peacekeepers are going to the town of Kerver to seek Chinese foreign aid engineers.
The military map shows that there are many checkpoints in the war zone. It can be modeled as a directed graph: nodes represent checkpoints , and edges represents the roads. The goal is that the less peacekeepers pass the checkpoints, the safer it will be.


做ACM的英文题,前几段落都可以不读,题意重点在最后两段。。
这题是求单源点最短路
用dijkstra跑一遍
南阳OJ过不了,郑轻可以AC。。。有时间再查问题
#include<bits/stdc++.h>
using namespace std;
int t;
int A,B;
const int MAX_N = 105;
const int MAX_M = 100000;
const int inf = 0x3f3f3f3f;
struct edge {
int v, w, next;
} e[MAX_M];
int p[MAX_N], eid, n,m;
void mapinit() {
memset(p, -1, sizeof(p));
eid = 0;
}
void insert(int u, int v, int w) { // 插入带权有向边
e[eid].v = v;
e[eid].w = w;
e[eid].next = p[u];
p[u] = eid++;
}
void insert2(int u, int v, int w) { // 插入带权双向边
insert(u, v, w);
insert(v, u, w);
}
int dist[MAX_N]; // 存储单源最短路的结果
bool vst[MAX_N]; // 标记每个顶点是否在集合 U 中
struct node {
int u;
int dist;
node(int _u, int _dist) : u(_u), dist(_dist) {}
bool operator < (const node &x) const {
return dist > x.dist;
}
}; // 记录点的结构体
bool dijkstra(int s) {
// 初始化 dist、小根堆和集合 U
memset(vst, 0, sizeof(vst));
memset(dist, 0x3f, sizeof(dist));
priority_queue<node> min_heap;
dist[s] = 0;
min_heap.push(node(s, 0));
while (!min_heap.empty()){
// 获取堆顶元素,并将堆顶元素从堆中删除
int v = min_heap.top().u;
min_heap.pop();
if (vst[v]) {
continue;
}
vst[v] = true;
// 进行和普通 dijkstra 算法类似的松弛操作
for (int j = p[v]; j != -1; j = e[j].next) {
int x = e[j].v;
if (!vst[x] && dist[v] + e[j].w < dist[x]) {
dist[x] = dist[v] + e[j].w;
min_heap.push(node(x, dist[x]));
}
}
}
return true;
}
int main(){
cin>>t;
while(t--){
cin>>n>>m>>A>>B;
mapinit();
for(int i=1;i<=m;i++){
int u,v;
cin>>u>>v;
insert(u,v,1);
}
dijkstra(A);
cout<<dist[B]<<endl;
}
return 0;
}
H Attack City and Capture Territory
Who breaks through the last firepower point, he will win the city.
Because of limited weaponry, weapons of each side can only attack one firepower at a time. But they can control whether completely destroy this firepower point or weaken the strength of firepower point.
Liu_B has a strong think-tank. After calculation, he finds out who will attack first , who will more likely win the city .
从最后两段中理解题意,是一个直接的nim博弈。

AC代码
#include<bits/stdc++.h>
using namespace std;
int t;
int a[1010];
int n;
int main(){
cin>>t;
while(t--){
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
int res = 0;
for(int i=1;i<=n;i++) res^=a[i];
if(res){
puts("Liu_B is sure to win.");
}else{
puts("Liu_B is not sure to win.");
}
}
return 0;
}
每天一套题打卡|河南省第十一届ACM/ICPC的更多相关文章
- 每天一套题打卡|河南省第九届ACM/ICPC
A 表达式求值 表达式求值:可以用递归求解,也可以用栈模拟,考过多次. 类似题目:NYOJ305,NYOJ35 用栈模拟做法: #include <stdio.h> #include &l ...
- 每天一套题打卡|河南省第十届ACM/ICPC
A.谍报分析 题意:请你编程,快速统计出频率高的前十个单词. 思路:字符串输入,map哈希表map<string,int >记录每个单词出现的次数,pair重载优先级 #include&l ...
- 每天一套题打卡|河南省第七届ACM/ICPC
A 海岛争霸 题目:Q次询问,他想知道从岛屿A 到岛屿B 有没有行驶航线,若有的话,所经过的航线,危险程度最小可能是多少. 多源点最短路,用floyd 在松弛更新:g[i][k] < g[i][ ...
- 每天一套题打卡|河南省第八届ACM/ICPC
A 挑战密室 化学方程式求分子量 这题我懒得写了 可以用map<string,int>哈希表,表示每种分子的相对分子质量 之后,从头遍历到尾. 1.数字:连读直到不是数字 2.字母:连读直 ...
- 河南省第十一届ACM大学生程序设计竞赛
nyoj-1365-山区修路 内存限制:128MB 时间限制:3000ms 特判: No通过数:4 提交数:4 难度:3 题目描述: SNJ位于HB省西部一片群峰耸立的高大山地,横亘于A江.B水之间, ...
- 递推水题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table
题目传送门 /* 模拟递推水题 */ #include <cstdio> #include <iostream> #include <cmath> #include ...
- [水题日常]UVA1639 糖果(Candy,ACM/ICPC Chengdu 2012)
今天来尝试了几道数学期望相关的题,这是我认为比较有趣的一道题 这次不废话啦直接开始~ 一句话题意:两个分别装有n个糖果的盒子,每次随机选一个盒子然后拿走一颗糖(选的概率分别是\(p\)和\((1-p) ...
- codeforces水题100道 第十八题 Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table (brute force)
题目链接:http://www.codeforces.com/problemset/problem/509/A题意:f[i][1]=f[1][i]=1,f[i][j]=f[i-1][j]+f[i][j ...
- 【河南省第十一届ACM大学生程序设计竞赛-D】.求XF+闭包
如何设计一个好的数据库不仅仅是一个理论研究问题,也是一个实际应用问题.在关系数据库中不满足规范化理论的数据库设计会存在冗余.插入异常.删除异常等现象. 设R(U)是一个关系模式,U={ A1,A ...
随机推荐
- python基础5 while循环
一.while循环: while 条件: 代码块 例: n=0 while n<10: print(n) n=n+1 #n自加1 ,满足n<10,继续循环 输出结果: 1 2 3 4 ...
- WinAPI 字符及字符串函数(9): lstrcat - 合并字符串
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, For ...
- robot framework 提示‘pybot 不是内部命令’
command: pybot.bat --argumentfile c:\*\RIDEzsxpul.d\argfile.txt --listener C:\Python27\lib\site-pack ...
- MVC Views文件夹下js无法访问问题解决方案
出现这个问题是因为webconfig做的限制,可修改相应Views下的webconfig文件来解决. <system.webServer> <handlers> <rem ...
- zblog如何更改数据库配置以及生效
zblog是一个博客的开源框架, 挺不错的,我们当前拿来作为新闻系统管理使用. 由于我们数据库需要统一使用RDS, 故对zblog数据库配置进行修改,修改文件如下: 1. 数据库文件地址: zb_us ...
- vi命令保存
:q :退出编辑器 :q! :强制退出 :wq :保存并退出 :wq! :保存并强制退出 ZZ :保存并退出 :x :保存并退出
- JMeter接口自动化测试实例—JMeter引用javaScript
Jmeter提供了JSR223 PreProcessor前置处理器,通过该工具融合了Java 8 Nashorn 脚本引擎,可以执行js脚本以便对脚本进行前置处理.其中比较典型的应用就是通过执行js脚 ...
- TCP 服务端接收数据解析工具类
package com.ivchat.common.util; import java.io.BufferedReader;import java.io.IOException;import java ...
- java快排思想
1分治思想 1.1比大小在分区 1.2从数组中取出一个数做基准数 1.3将比他小的数全放在他的左边,比他大的数全放在他的右边 1.4然后递归 左边 和右边 }
- spark MLlib实现的基于朴素贝叶斯(NaiveBayes)的中文文本自动分类
1.自动文本分类是对大量的非结构化的文字信息(文本文档.网页等)按照给定的分类体系,根据文字信息内容分到指定的类别中去,是一种有指导的学习过程. 分类过程采用基于统计的方法和向量空间模型可以对常见的文 ...