Problem A. Jhadgre的C语言程序

签。

 #include <bits/stdc++.h>
using namespace std; int main()
{
puts("Helle World!");
return ;
}

Problem B. Wpremig的AH之战

Solved.

  • 如果 $n >= m 直接赢$
  • 否则 $易知必败局面是当前剩余数是(n + 1)的倍数$
 #include<bits/stdc++.h>

 using namespace std;

 int n, m;

 int main()
{
while(~scanf("%d %d", &n, &m))
{
if(n >= m)
{
for(int i = m; i <= n; ++i)
printf("%d%c", i, " \n"[i == n]);
}
else
{
if(m % (n + ) == ) puts("You are loser");
else printf("%d\n", m % (n + ));
}
}
return ;
}

Problem D. Jhadgre的梯子

温暖的签。

 #include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 100010
int n;
ll m, x, Max; int main()
{
while (scanf("%d%lld", &n, &m) != EOF)
{
Max = ;
for (int i = ; i <= n; ++i)
{
scanf("%lld", &x);
Max = max(Max, x);
}
printf("%lld\n", max(0ll, Max - m));
}
return ;
}

Problem E. Jhadgre的合唱队形

Solved.

题意:

有$n个队列,两种操作$

  • $1\; x\; y\; z \;\;将编号属于[x, y]的队列最后加入一个z$
  • $2\; x\; y\; z \;\; 询问编号属于[x, y]的所有队列中的所有人中第z大的数是多少$

思路:

本来想分块维护三个BIT,但是发现空间炸了。

那找第$k大的数可以二分,多次询问,就整体二分$

对于每个询问二分答案,在时间线中,在你前面的 并且 值小于你二分的答案就加入线段树

查询的时候直接查,记得更新k,然后将询问分组即可

 #include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 50010
int n, m, Q; namespace SEG
{
ll sum[N << ], lazy[N << ];
void pushdown(int id, int l, int mid, int r)
{
if (!lazy[id]) return;
sum[id << ] += 1ll * (mid - l + ) * lazy[id];
lazy[id << ] += lazy[id];
sum[id << | ] += 1ll * (r - mid) * lazy[id];
lazy[id << | ] += lazy[id];
lazy[id] = ;
}
void update(int id, int l, int r, int ql, int qr, int v)
{
if (l >= ql && r <= qr)
{
sum[id] += 1ll * v * (r - l + );
lazy[id] += v;
return;
}
int mid = (l + r) >> ;
pushdown(id, l, mid, r);
if (ql <= mid) update(id << , l, mid, ql, qr, v);
if (qr > mid) update(id << | , mid + , r, ql, qr, v);
sum[id] = sum[id << ] + sum[id << | ];
}
ll query(int id, int l, int r, int ql, int qr)
{
// printf("%d %d %d %d\n", l, r, ql, qr);
if (l >= ql && r <= qr) return sum[id];
int mid = (l + r) >> ;
pushdown(id, l, mid, r);
ll res = ;
if (ql <= mid) res += query(id << , l, mid, ql, qr);
if (qr > mid) res += query(id << | , mid + , r, ql, qr);
return res;
}
} struct node
{
int op, l, r, z, id;
node () {}
node (int op, int l, int r, int z, int id) : op(op), l(l), r(r), z(z), id(id) {}
}q[N << ], ql[N << ], qr[N << ];
int ans[N]; void CDQ(int L, int R, int l, int r)
{
if (L > R) return;
if (l == r)
{
for (int i = L; i <= R; ++i) if (q[i].op == )
ans[q[i].id] = l;
return;
}
int mid = (l + r) >> ;
int cnt_ql = , cnt_qr = ;
for (int i = L; i <= R; ++i)
{
if (q[i].op == )
{
if (q[i].z <= mid)
{
SEG::update(, , n, q[i].l, q[i].r, );
ql[++cnt_ql] = q[i];
}
else
qr[++cnt_qr] = q[i];
}
else
{
ll sze = SEG::query(, , n, q[i].l, q[i].r);
if (sze < q[i].z)
{
q[i].z -= sze;
qr[++cnt_qr] = q[i];
}
else
ql[++cnt_ql] = q[i];
}
}
for (int i = ; i <= cnt_ql; ++i) if (ql[i].z <= mid) SEG::update(, , n, ql[i].l, ql[i].r, -);
for (int i = ; i <= cnt_ql; ++i) q[L + i - ] = ql[i];
for (int i = ; i <= cnt_qr; ++i) q[L + cnt_ql + i - ] = qr[i];
CDQ(L, L + cnt_ql - , l, mid);
CDQ(L + cnt_ql, R, mid + , r);
} int main()
{
while (scanf("%d%d", &n, &Q) != EOF)
{
m = ;
memset(ans, , sizeof ans);
for (int i = , op, x, y, z; i <= Q; ++i)
{
scanf("%d%d%d%d", &op, &x, &y, &z);
if (op == ) q[++m] = node(, x, y, -z, i);
else q[++m] = node(, x, y, z, i);
}
CDQ(, m, -n, -);
for (int i = ; i <= Q; ++i) if (ans[i])
printf("%d\n", -ans[i]);
}
return ;
}

Problem F. Jhadgre的伤心地

演了一波,小dp写成最短路、搜索可还行

 #include<bits/stdc++.h>

 using namespace std;

 typedef long long ll;

 const int maxn = 1e3 + ;

 int n;
ll a[maxn];
ll dis[maxn];
int vis[maxn]; void BFS()
{
memset(vis, , sizeof vis);
memset(dis, 0x3f, sizeof dis);
vis[] = ;
dis[] = ;
queue<int>q;
q.push();
while(!q.empty())
{
int u = q.front();
q.pop();
if(!vis[min(n, u + )])
{
dis[min(n, u + )] = dis[u] + ;
vis[min(n, u + )] = ;
q.push(min(n, u + ));
} if(!vis[min(n * 1ll, a[u])])
{
dis[min(n * 1ll, a[u])] = dis[u] + ;
vis[min(n * 1ll, a[u])] = ;
q.push(min(n * 1ll, a[u]));
}
}
} int main()
{
while(~scanf("%d", &n))
{
n++;
for(int i = ; i <= n - ; ++i)
{
scanf("%d", a + i);
a[i] = min(a[i], n * 1ll);
}
BFS();
printf("%lld\n", dis[n]);
}
return ;
}

Problem H. Jhadgre的回家之路

Solved.

两次搜索,搜'L' -> 'W' 和 'Q' -> 'W' 枚举'W'位置更新答案

薛佬交了三发,Rejudge后第一发其实就过

 #include<bits/stdc++.h>

 using namespace std;

 const int INF = 0x3f3f3f3f;
const int maxn = 2e3 + ; int n, m;
int vis[maxn][maxn];
int dis1[maxn][maxn];
int dis2[maxn][maxn];
char mp[maxn][maxn];
int dir[][] = {, , , ,-, ,, -}; struct node{
int x, y;
node(){}
node(int x,int y):x(x), y(y){};
}Q,L; bool check(int x, int y)
{
if(x < || x > n || y < || y > m || mp[x][y] == '#' || vis[x][y]) return false;
else return true;
} vector<node>W; void BFS1()
{
memset(vis, , sizeof vis);
memset(dis1, INF, sizeof dis1);
vis[L.x][L.y] = ;
dis1[L.x][L.y] = ;
queue<node>q;
q.push(L);
while(!q.empty())
{
node st = q.front();
q.pop();
for(int i = ; i< ; ++i)
{
node now;
now.x = st.x + dir[i][];
now.y = st.y + dir[i][];
if(check(now.x, now.y))
{
vis[now.x][now.y] = ;
dis1[now.x][now.y] = dis1[st.x][st.y] + ;
q.push(now);
}
}
}
} void BFS2()
{
memset(vis, , sizeof vis);
memset(dis2, INF, sizeof dis2);
vis[L.x][L.y] = ;
dis2[Q.x][Q.y] = ;
queue<node>q;
q.push(Q);
while(!q.empty())
{
node st = q.front();
q.pop();
for(int i = ; i< ; ++i)
{
node now;
now.x = st.x + dir[i][];
now.y = st.y + dir[i][];
if(check(now.x, now.y))
{
vis[now.x][now.y] = ;
dis2[now.x][now.y] = dis2[st.x][st.y] + ;
q.push(now);
}
}
}
} int main()
{
while(~scanf("%d %d", &n, &m))
{
for(int i = ; i <= n; ++i)
{
for(int j = ; j <= m; ++j)
{
scanf(" %c", &mp[i][j]);
if(mp[i][j] == 'Q')
{
Q = node(i, j);
}
else if(mp[i][j] == 'L')
{
L = node(i, j);
}
else if(mp[i][j] == 'W')
{
W.push_back(node(i, j));
}
}
}
BFS1();
BFS2();
int ans = INF;
for(auto it: W)
{
ans = min(dis1[it.x][it.y] + dis2[it.x][it.y], ans);
}
printf("%d\n", ans);
}
return ;
}

Problem I. Jhadgre的小饼干

string.find()

 #include<bits/stdc++.h>

 using namespace std;

 int n;
string s; int main()
{
ios::sync_with_stdio(false);
cin.tie();
cout.tie();
while(cin >> n)
{
int sum = ;
for(int i = ; i <= n; ++i)
{
cin >> s;
if(s.find("zailaiyihe") != s.npos) sum++;
}
printf("%d\n", sum);
}
return ;
}

Problem J. Jhadgre爬楼梯

线性推

 #include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 10010
const ll MOD = (ll);
int n;
ll f[N], sum[]; int main()
{
f[] = ;
sum[] = , sum[] = ;
for (int i = ; i <= ; ++i)
{
f[i] = f[i - ];
f[i] = (f[i] + sum[i & ]) % MOD;
sum[i & ] = (sum[i & ] + f[i]) % MOD;
}
while (scanf("%d", &n) != EOF) printf("%lld\n", f[n]);
return ;
}

Problem L. Wpremig's Niuniu

题意:

规则:

五张牌均严格小于5,五张牌的和小于等于10,得60分。

五张牌都是$J,Q,K$,得50分。

五张牌有四张牌相同,得40分。

如果其中三张牌的和是10的倍数,并且其他两张牌的和是10的倍数,得30分

如果其中三张牌的和是10的倍数,并且其他两张牌的和对于10的余数大于等于7,得$2*$其他两张牌的和对于10的余数

如果其中三张牌的和是10的倍数,并且其他两张牌的和对于10的余数大于等于7,得其他两张牌的和对于10的余数

其余情况不得分,同时每次只能获取最高分。

现在你手上已经有四张牌,求拿到第五张牌后的分数期望(四舍五入)

思路:

预处理出所有情况,最后遍历一次得到总分后除以13

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + ; int ans[][][][][]; void Init()
{
for (int a = ; a <= ; ++a)
{
for (int b = ; b <= ; ++b)
{
for (int c = ; c <= ; ++c)
{
for (int d = ; d <= ; ++d)
{
for (int e = ; e <= ; ++e)
{
if (a < && b < && c < && d < && e < && a + b + c + d + e <= )
{
ans[a][b][c][d][e] = ;
}
else if (a >= && b >= && c >= && d >= && e >= )
{
ans[a][b][c][d][e] = ;
}
else if ((a == b && b == c && c == d) || (a == b && b == c && c == e) || (a == b && b == d && d == e) || (a == c && c == d && d == e) || (b == c && c == d && d == e))
{
ans[a][b][c][d][e] = ;
}
else
{
if ((min(, a) + min(, b) + min(, c)) % == || (min(, a) + min(, b) + min(, d)) % == || (min(, a) + min(, b) + min(, e)) % == || (min(, a) + min(, c) + min(, d)) % == || (min(, a) + min(, c) + min(, e)) % == || (min(, a) + min(, d) + min(, e)) % ==
|| (min(, b) + min(, c) + min(, d)) % == || (min(, b) + min(, c) + min(, e)) % == || (min(, b) + min(, d) + min(, e)) % == || (min(, b) + min(, d) + min(, e)) % ==
|| (min(, c) + min(, d) + min(, e)) % == )
{
int sum = min(, a) + min(, b) + min(, c) + min(, d) + min(, e);
if (sum % == ) ans[a][b][c][d][e] = ;
else if (sum % >= ) ans[a][b][c][d][e] = * (sum % );
else ans[a][b][c][d][e] = sum % ;
}
}
}
}
}
}
}
} void RUN()
{
Init();
int t;
scanf("%d", &t);
while (t--)
{
int a, b, c, d;
scanf("%d %d %d %d", &a, &b, &c, &d);
int sum = ;
for (int i = ; i <= ; ++i) sum += ans[a][b][c][d][i];
sum = (sum / 13.0) + 0.5;
printf("%d\n", sum);
}
} int main()
{
#ifdef LOCAL_JUDGE
freopen("Text.txt", "r", stdin);
#endif // LOCAL_JUDGE RUN(); #ifdef LOCAL_JUDGE
fclose(stdin);
#endif // LOCAL_JUDGE
return ;
}

枚举最后一张牌,求总分,最后除以13

#include<bits/stdc++.h>

using namespace std;

int a[], b[];
int c[]; void RUN()
{
int t;
scanf("%d", &t);
while (t--)
{
for (int i = ; i <= ; ++i) scanf("%d", a + i);
b[] = min(, a[]) + min(, a[]);
b[] = min(, a[]) + min(, a[]);
b[] = min(, a[]) + min(, a[]);
b[] = min(, a[]) + min(, a[]);
b[] = min(, a[]) + min(, a[]);
b[] = min(, a[]) + min(, a[]);
b[] = ;
int tmp = ;
for (int i = ; i <= ; ++i) tmp += min(, a[i]);
for (int i = ; i <= ; ++i)
{
if ((tmp - min(, a[i])) % == )
{
b[] = ;
break;
}
} double ans = ;
for (int i = ; i <= ; ++i)
{
a[] = i;
//
if (a[] < && a[] < && a[] < && a[] < && a[] < && a[] + a[] + a[] + a[] + a[] <= )
{
ans += 60.0;
continue;
} //
if (a[] >= && a[] >= && a[] >= && a[] >= && a[] >= )
{
ans += 50.0;
continue;
} //
if ((a[] == a[] && a[] == a[] && a[] == a[]) || (a[] == a[] && a[] == a[] && a[] == a[]) || (a[] == a[] && a[] == a[] && a[] == a[]) || (a[] == a[] && a[] == a[] && a[] == a[]) || (a[] == a[] && a[] == a[] && a[] == a[]))
{
ans += 40.0;
continue;
} //
int sum = ;
for (int i = ; i <= ; ++i) sum += min(, a[i]);
if (b[])
{
if (sum % == ) ans += 30.0;
else if (sum % >= ) ans += 2.0 * (sum % );
else ans += sum % ;
continue;
}
//
int res = -;
for (int j = ; j <= ; ++j)
{
if ((b[j] + min(, a[])) % == )
{
res = sum % ;
break;
}
}
if (res == -) continue;
if (res == ) ans += 30.0;
else if (res >= ) ans += 2.0 * res;
else if (res != -) ans += res;
}
ans = (ans / 13.0) + 0.5;
printf("%d\n", (int)ans);
} } int main()
{
#ifdef LOCAL_JUDGE
freopen("Text.txt", "r", stdin);
#endif // LOCAL_JUDGE RUN(); #ifdef LOCAL_JUDGE
fclose(stdin);
#endif // LOCAL_JUDGE
return ;
}

比赛的时候写丑了,同时对于题意理解不明确?(说好的一副牌呢!)

2018年浙江中医药大学程序设计竞赛 Solution的更多相关文章

  1. 2017年浙江中医药大学程序设计竞赛 Solution

    训练地址 A: 树剖板子题 求最小值的时候要注意值是不是有负数,如果有,初值要置为$-INF$ #include <bits/stdc++.h> using namespace std; ...

  2. 2018年浙江理工大学程序设计竞赛校赛 Problem I: 沙僧

    沙僧 思路: dfs序+差分数组 分层考虑,通过dfs序来查找修改的区间段,然后用差分数组修改 代码: #include<bits/stdc++.h> using namespace st ...

  3. 2018 ACM 国际大学生程序设计竞赛上海大都会部分题解

    题目链接 2018 ACM 国际大学生程序设计竞赛上海大都会 下午午休起床被同学叫去打比赛233 然后已经过了2.5h了 先挑过得多的做了 .... A题 rand x*n 次点,每次judge一个点 ...

  4. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  5. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 F题 Clever King(最小割)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  6. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it

    链接:https://www.nowcoder.com/acm/contest/163/F 来源:牛客网 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it 时间限制:C ...

  7. 北京化工大学2018年10月程序设计竞赛部分题解(A,C,E,H)

    目录 北京化工大学2018年10月程序设计竞赛部分题解(A,C,E,H) 竞赛事件相关 竞赛链接 竞赛题目 总结 北京化工大学2018年10月程序设计竞赛部分题解(A,C,E,H) 竞赛事件相关 竞赛 ...

  8. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it (扫描线) 链接:https://ac.nowcoder.com/acm/contest/163/F来源:牛客网 时间 ...

  9. 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP)

    2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 J Beautiful Numbers (数位DP) 链接:https://ac.nowcoder.com/acm/contest/163/ ...

随机推荐

  1. 解决IE中img.onload失效的方法

    解决IE中img.onload失效的方法 - CoffeeCat's IT Blog - IT博客 http://www.cnitblog.com/CoffeeCat/archive/2008/02/ ...

  2. OnGlobalLayoutListener用法

    1.implements ViewTreeObserver.OnGlobalLayoutListener{} 2.mContentView.getViewTreeObserver().addOnGlo ...

  3. Android底层有一定的认识,研究过相关的Android源码

    一.系统架构: 一).系统分层:(由下向上)[如图] 1.安卓系统分为四层,分别是Linux内核层.Libraries层.FrameWork层,以及Applications层: 其中Linux内核层包 ...

  4. Apache nutch1.5 & Apache solr3.6

    第1章引言 1.1nutch和solr Nutch 是一个开源的.Java 实现的搜索引擎.它提供了我们运行自己的搜索引擎所需的全部工具. Solr 拥有像 web-services API 的独立的 ...

  5. Effective C++ —— 构造/析构/赋值运算(二)

    条款05 : 了解C++默默编写并调用哪些函数 编译器可以暗自为class创建default构造函数.copy构造函数.copy assignment操作符,以及析构函数. 1. default构造函 ...

  6. Ubuntu14.04下安装DevStack

    虚拟机中的网络配置 NET8 为nat net2 为host-only 虚拟机网络配置 # The primary network interface vmnet nat type auto eth0 ...

  7. ubuntu下nginx编译安装

    安装依赖库: sudo apt-get install libgd2-xpm sudo apt-get install libgd2-xpm-dev sudo apt-get install libg ...

  8. Express框架(http服务器 + 路由)

    index.js 使用express框架搭建http服务器,和实现路由功能. var express = require('express'); var app = express(); // 主页输 ...

  9. shell批量重命令文件脚本

    批量重命名脚步记录,以备用 假如有一批11.txt 12.txt 13,txt 14.txt 15.txt脚步要要重命名为1.txt 2.txt 3.txt .... 脚本如下: #!/bin/bas ...

  10. ExcelUtil工具类

    import com.google.common.base.Strings;import com.jianwu.util.excel.annotation.ExcelAttribute;import ...