每天一套题打卡|河南省第十一届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 ...
随机推荐
- Django ORM存储datetime 时间误差8小时问题
今天使用django ORM 将获取到的时间入库,并未出现问题,但是后来发现时间晚了8小时,经查询Django官方文档发现获取本地时间和UTC时间有差别. 首先科普下:UTC是协调世界时 UTC相当于 ...
- 5.6版本GTID复制异常处理一例(转)
http://imysql.com/2014/07/31/mysql-faq-exception-replication-with-gtid.shtml 昨天处理了一个MySQL 5.6版本下开启GT ...
- java框架之SpringBoot(17)-监控管理
介绍 SpringBoot 提供了监控管理功能的场景启动器,它可以为我们提供准生产环境下的应用监控和管理功能.我们可以通过HTTP.JMX.SSH协议来进行操作,自动得到审计.健康及指标信息等. 使用 ...
- python 时间戳和时间格式互相转换
#!/usr/bin/python3 # -*- coding: utf-8 -* import time def str_to_stamp(): # 转换显示格式 time1 = time.strp ...
- 【LeetCode每天一题】Edit Distance(编辑距离)
Given two words word1 and word2, find the minimum number of operations required to convert word1 to ...
- Postman接口自动化测试实例二
在<Postman接口自动化测试实例>一文中,我是在获取随机因子的接口的Tests中对用户的密码进行加密处理的.其实正常做法应该是在请求验证接口前,即在Pre-request Script ...
- python爬虫简单的添加代理进行访问
在使用python对网页进行多次快速爬取的时候,访问次数过于频繁,服务器不会考虑User-Agent的信息,会直接把你视为爬虫,从而过滤掉,拒绝你的访问,在这种时候就需要设置代理,我们可以给proxi ...
- 学Python的感受
这门课程已经上了两周了,虽然还没学到什么实质上的东西,只是做了几道题,但是我也感受到了Python的魅力.我感觉这门课真的很有用,比如老师所说的网络爬虫,我对这个非常感兴趣.再说说老师的教学方式,理论 ...
- windows下redis 配置文件参数说明
1.先看redis.windows.conf 文件 # Redis configuration file example # Note on units: when memory size is ne ...
- Linux 系统的启动过程
1.基本概念 BIOS 中文名 主板BIOS 外文名 Basic Input/Output System 全 称 基本输入输出系统(全称是ROM-BIOS,是只读存储器基本输入/输出 ...