[ACM][2018南京预赛]Magical Girl Haze】的更多相关文章

一.题面 样例输入: 15 6 11 2 21 3 42 4 33 4 13 5 64 5 2 样例输出: 3 二.思路 关键词:分层BFS 考试时觉得题干意思很清晰——求可将k条边赋值为0的最短路.起初几个思路正确性均存疑,后来觉得应该要DP于是决定滞后了... 正解——分层BFS,个人认为思路与DP有些许相像,同时记录节点及当前已赋值为0的边数,则在跑最短路时(这里用的SPFA),可选择是否将该条边赋值为0,当且仅当已选边<k. 三.代码 #include <cstdio> #inc…
一.题面 样例输入: 5 4 3 10 5 2 7 10 5 1 4 8 7 2 3 6 4 7 样例输出: 4 0 1 1 3 6 5 1 5 1 2 0 3 2 4 4 3 6 5 1 二.思路 关键词:线段树 这道题最难就难在看题吧...也许ACM的魅力之一便在于此——面对若干道题,你不知每一道题的难度是高是低,只能耐心地读清题面,审清题意,理清思路,方可知其是否在能力范围内以及预估耗时.考试过程中,我基本靠board来判断题目难度,清北大佬们先AC了哪些我就先做哪些...然而这道题似乎他…
一.题面 样例输入: 2 5 8 样例输出: 8 14 二.思路 关键词:线性筛 在Zed的帮助下知道了这是一道线性筛的比较裸的题了.考试过程中肝这道题的时间最久,费了心思找到递推式后,发现根本不是在1s内能实现的东西.考试过程中大三学长选择了暴力打表打了几十KB...考后向Zed请教良久知道了线性筛.线性筛最基础的作用是筛出所有质数,时间复杂度仅为o(n).由于f(x)是“积性函数”(f(a * b) = f(a) * f(b)),所以也可以用线性筛处理. 三.代码 #include <cst…
262144K   There are NN cities in the country, and MM directional roads from uu to v(1\le u, v\le n)v(1≤u,v≤n). Every road has a distance c_ici​. Haze is a Magical Girl that lives in City 11, she can choose no more than KK roads and make their distanc…
轻轻松松也能拿到区域赛名额,CCPC真的好难 An Olympian Math Problem 问答 只看题面 54.76% 1000ms 65536K   Alice, a student of grade 66, is thinking about an Olympian Math problem, but she feels so despair that she cries. And her classmate, Bob, has no idea about the problem. T…
ACM-ICPC 2018 南京赛区网络预赛 A. An Olympian Math Problem 计算\(\sum_{i=1}^{n-1}i\cdot i!(MOD\ n)\) \(\sum_{i=1}^{n-1}i\cdot i! = \sum_{i=1}^{n-1}[(i+1)!-i!](MOD\ n)=n!-1!(MOD\ n)=n-1\) #include<bits/stdc++.h> using namespace std; int T; long long n; int mai…
A square-free integer is an integer which is indivisible by any square number except 11. For example, 6 = 2 \cdot 36=2⋅3 is square-free, but 12 = 2^2 \cdot 312=22⋅3 is not, because 2^222 is a square number. Some integers could be decomposed into prod…
ACM-ICPC 2018 南京赛区网络预赛 E题 题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest with n (0 < n \le 20)n(0<n≤20) problems. And he knows the answer of all of these problems. However, he can submit ii-th problem if and only if he has s…
题目链接:https://nanti.jisuanke.com/t/30991 Feeling hungry, a cute hamster decides to order some take-away food (like fried chicken for only 3030 Yuan). However, his owner CXY thinks that take-away food is unhealthy and expensive. So she demands her hams…
J. Sum 26.87% 1000ms 512000K   A square-free integer is an integer which is indivisible by any square number except 11. For example, 6 = 2 \cdot 36=2⋅3 is square-free, but 12 = 2^2 \cdot 312=22⋅3 is not, because 2^222 is a square number. Some integer…
G. Lpl and Energy-saving Lamps 42.07% 1000ms 65536K   During tea-drinking, princess, amongst other things, asked why has such a good-natured and cute Dragon imprisoned Lpl in the Castle? Dragon smiled enigmatically and answered that it is a big secre…
A. An Olympian Math Problem 54.28% 1000ms 65536K   Alice, a student of grade 66, is thinking about an Olympian Math problem, but she feels so despair that she cries. And her classmate, Bob, has no idea about the problem. Thus he wants you to help him…
题目链接:https://nanti.jisuanke.com/t/30991 2000ms 262144K   Feeling hungry, a cute hamster decides to order some take-away food (like fried chicken for only 3030 Yuan). However, his owner CXY thinks that take-away food is unhealthy and expensive. So she…
A. An Olympian Math Problem cout << n - 1 << endl; #include <bits/stdc++.h> using namespace std; #define ll long long int t; ll n; inline void Run() { scanf("%d", &t); while (t--) { scanf("%lld", &n); printf()…
2018南京I题: dinic,链式前向星,数组队列,当前弧优化,不memset全部数组,抛弃满流点,bfs只找一条增广路,每次多路增广 #include <bits/stdc++.h> #define ll long long #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define rep(ii,a,b) for(int ii=a;ii<=b;++ii) using namespace std; con…
layout: post title: Mediocre String Problem (2018南京M,回文+LCP 3×3=9种做法 %%%千年好题 感谢"Grunt"大佬的细心讲解) author: "luowentaoaa" catalog: true mathjax: true tags: - 回文树 - 马拉车 - 扩展KMP - 后缀数组 - 后缀自动机 - 字符串哈希 题意 给出一个串S,和一个串T. 要求 从S串中取一个子串,后面接上T串的一个前缀…
题目顺序:A C E G I J L A. An Olympian Math Problem 打表,找规律,发现答案为n-1 C. GDY 题意: m张卡片,标号1-13: n个玩家,标号1-n:每个人拿前5个卡片 玩家1先出牌(最小),其他玩家2-n顺时针标号从1-n-1出牌 轮到当前玩家出牌,如果有比上一次的出牌大1,可以直接出:没有大1的牌,若有2出2:若都没有,这一轮跳过他 如果一轮中,玩家x出了一张最大的牌,玩家x~n,1~x中所有玩家都没有出牌,从玩家x开始所有玩家都拿一张牌(如 果…
There are N cities in the country, and M directional roads from u to v(1≤u,v≤n). Every road has a distance ci. Haze is a Magical Girl that lives in City 1, she can choose no more than K roads and make their distances become 0. Now she wants to go to…
类似题解 There are NN cities in the country, and MM directional roads from uu to v(1\le u, v\le n)v(1≤u,v≤n). Every road has a distance c_ici​. Haze is a Magical Girl that lives in City 11, she can choose no more than KK roads and make their distances be…
There are NN cities in the country, and MMdirectional roads from uu to v(1\le u, v\le n)v(1≤u,v≤n). Every road has a distance c_ici​. Haze is a Magical Girl that lives in City 11, she can choose no more than KK roads and make their distances become 0…
题意:N个点,M条带权有向边,求可以免费K条边权值的情况下,从点1到点N的最短路. 分析:K<=10,用dist[i][j]表示从源点出发到点i,免费j条边的最小花费.在迪杰斯特拉的dfs过程中,每个结点表示的状态有三个属性:访问至的结点,免费的边数和最小花费.将免费的边数看作层,则该图被分为k层.每次更新除了要对边进行松弛操作,也要对层之间进行松弛操作. #include<bits/stdc++.h> using namespace std; typedef long long LL;…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 定义dis[i][j]表示到达i这个点. 用掉了j次去除边的机会的最短路. dis[1][0]= 0; 在写松弛条件的时候. 如果用了去除边的机会. 就把机会+1再更新最短路就好. 用spfa会超时. 写个dijkstra+优先队列优化就ok 在dis[n][0..k]中找最小值就好. [代码] #include <bits/stdc++.h> #define LL long long #define ms(a,b) mems…
题意: 就是使不大于k条路的权值变为零后求最短路 解析: d[i][j]表示使j条路变为权值后从起点到点i的最短路径 这题不能用spfa做  tle #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <cctype> #include <set> #include <v…
大致题意: 给定一个n个点m条边的图,在可以把路径上至多k条边的权值变为0的情况下,求S到T的最短路. 数据规模: N≤100000,M≤200000,K≤10 建一个立体的图,有k层,每一层是一份原图,消耗一次把一条边权值变为0的机会 = 在立体图中升一层 然后跑堆优化dij就好了,会卡spfa. AC代码: #include<cstdio> #include<queue> #include<cstring> #define rep(i,a,b) for(int i=…
题目链接:https://nanti.jisuanke.com/t/31001 题意: 一带权有向图,有 n 个节点编号1~n,m条有向边,现在一人从节点 1 出发,他有最多 k 次机会施展魔法使得某一条边的权变成 0,问他走到节点 n 的最小权值为多少. 题解: 将dist数组和vis数组都扩展一维: dist[c][i]代表:已经使用了 c 次变0魔法后,走到节点 i 的最短距离: vis[c][i]代表:已经使用了 c 次变0魔法后,走到节点 i 的最短距离,这个最短距离是否已经被准确计算…
传送门:https://nanti.jisuanke.com/t/A1958 题意:n个点m条边的路,你有k次机会将某条路上的边权变为0,问你最短路径长度 题解:最短路变形,我们需要在常规的最短路上多开 一维,记录,我消耗j次机会时的最短路径长度为多少 代码: /** * ┏┓ ┏┓ * ┏┛┗━━━━━━━┛┗━━━┓ * ┃ ┃ * ┃ ━ ┃ * ┃ > < ┃ * ┃ ┃ * ┃... ⌒ ... ┃ * ┃ ┃ * ┗━┓ ┏━┛ * ┃ ┃ Code is far away fro…
题目链接:https://nanti.jisuanke.com/t/31001 解题心得: 一个BZOJ的原题,之前就写过博客了. 原题地址:https://www.lydsy.com/JudgeOnline/problem.php?id=2763 原题博客:https://www.cnblogs.com/GoldenFingers/p/9574230.html 比赛的时候遇到这个题第一个反应就是原题,然后用了以前的代码,WA:单向边,以前代码上是双向边.TLE:这个题出题人还卡了一下网格图.…
题目链接:https://nanti.jisuanke.com/t/30999 参考自博客:https://kuangbin.github.io/2018/09/01/2018-ACM-ICPC-Nanjing-online-J/ 题目中文: 1000毫秒 512000K 无方形整数是一个整数,除了1以外的任何平方数都不可分 这个数.例如,6 = 2 *3,6=2*3,6是无方形整数,但12 = 2 ^ 2*3,,因为2 ^ 2是正方形数.有些整数可以分解为两个无方形整数的乘积,可能有多种分解方…
Day 1: 早上6点起床打车去车站,似乎好久没有这么早起床过了,困到不行,在火车上睡啊睡就睡到了南京.南航离南京南站很近,地铁一站就到了,在学校里看到了体验坐直升机的活动,感觉很强.报道完之后去吃了一波食堂,感觉南航食堂装修非常有情调,饭菜种类也很多,打菜的小哥很热情,看到我们用的是20元的饭票但没凑够20块,还送了饮料. 下午热身赛前没事干,给jsb传授了一些玩植物大战僵尸2的经验.热身赛的体验并不很好,机器很卡,没有我们平时习惯用的gedit,写代码的时候保存一下就会卡一会儿,一开始PC2…
A  签到题 Alice, a student of grade 666, is thinking about an Olympian Math problem, but she feels so despair that she cries. And her classmate, Bob, has no idea about the problem. Thus he wants you to help him. The problem is: We denote k!k!k!: k!=1×2×…