nx

test20190828

一个人想着一个人 提交于 2019-11-28 19:54:41
闲扯 今天原题大赛?? 三道题,三个巨佬做过,还有一个昨晚刚做的。。。。 题面 题面 \(T1\) Solution 没学过回文自动机, 咕咕咕 。 \(T2\) Solution 解法一:动态淀粉质 解法二:树剖 \(+\) 线段树 解法三:CDQ \(+\) 虚树 \(+\) \(DP\) 解法四:线段树 \(+\) 乱搞 前面三种解法都是大佬们想出来的,复杂度都是 \(O(n\log^2 n)\) 。最后一个是蒟蒻我在想不出正解的情况下乱搞的,没想到过了。。。 果然学校的考试数据很水啊。。 极限的话会被卡到 \(O(\frac{n^2}{2}\log n)\) ,但是随即数据下树的深度是 \(\log n\) 的,所以随机情况下是 \(n\log^2 n\) 。 具体解法还是咕了吧,巨佬们随便看看就懂了 Code #include<bits/stdc++.h> #define del(a,i) memset(a,i,sizeof(a)) #define ll long long #define inl inline #define il inl void #define it inl int #define ill inl ll #define re register #define ri re int #define rl re ll #define mid ((l+r)>

SCOI2009 围豆豆

。_饼干妹妹 提交于 2019-11-28 19:47:28
围豆豆 游戏的规则非常简单,在一个N×M的矩阵方格内分布着D颗豆子,每颗豆有不同的分值Vi。游戏者可以选择任意一个方格作为起始格,每次移动可以随意的走到相邻的四个格子,直到最终又回到起始格。最终游戏者的得分为所有被路径围住的豆豆的分值总和减去游戏者移动的步数。矩阵中某些格子内设有障碍物,任何时刻游戏者不能进入包含障碍物或豆子的格子。游戏者可能的最低得分为0,即什么都不做。 注意路径包围的概念,即某一颗豆在路径所形成的多边形(可能是含自交的复杂多边形)的内部。下面有两个例子: 第一个例子中,豆在路径围成的矩形内部,所以豆被围住了。第二个例子中,虽然路径经过了豆的周围的8个格子,但是路径形成的多边形内部并不包含豆,所以没有围住豆子。 布布最近迷上了这款游戏,但是怎么玩都拿不了高分。聪明的你决定写一个程序来帮助他顺利通关。 题解 如何判断一个点在多边形内部?从这个点引一条射线不与多边形的任何顶点相交(这样的射线一定存在),若射线与多边形的边的交点有奇数个则在内部,否则在外部。 D 很小,考虑状压 DP。 预处理出豆子的坐标和每个状态 S 下所有豆子的得分和 sum[S]。 首先枚举一个起点 (x,y)。设 f[i][j][S] 表示走到了 (i,j) 这个格子,当前圈住的豆子的状态为 S 的最小边界长度。这个像斯坦纳树去掉子集枚举的部分。 然后,枚举状态 S。因为要走一条回路,所以用

2019 HDOJ Multi-University Training Contest Stage 10(杭电多校)

♀尐吖头ヾ 提交于 2019-11-28 18:58:46
最后一场多校打得一般般。 题目链接: http://acm.hdu.edu.cn/contests/contest_show.php?cid=857 C: E: I: BFS水题。 1 /* Codeforces Contest 2019_mutc_10 2 * Problem I 3 * Au: SJoshua 4 */ 5 #include <queue> 6 #include <cstdio> 7 #include <vector> 8 #include <string> 9 #include <iostream> 10 11 using namespace std; 12 13 bool board[2002][2002]; 14 int n, m, q; 15 16 const int movement[4][2] = { 17 {0, 1}, {0, -1}, {1, 0}, {-1, 0} 18 }; 19 20 struct pos { 21 int x, y; 22 }; 23 24 int solve(int x, int y) { 25 int ans = 0; 26 if (board[x][y]) { 27 queue <pos> q; 28 q.push({x, y}); 29 while (!q.empty()) { 30 auto t = q

poj3669 Meteor Shower (宽度优先搜索)

泪湿孤枕 提交于 2019-11-28 15:22:18
Description - 题目描述 Bessie听说有场史无前例的流星雨即将来临;有谶言:陨星将落,徒留灰烬。为保生机,她誓将找寻安全之所(永避星坠之地)。目前她正在平面坐标系的原点放牧,打算在群星断其生路前转移至安全地点。 此次共有M (1 ≤ M ≤ 50,000)颗流星来袭,流星i将在时间点Ti (0 ≤ Ti ≤ 1,000) 袭击点 (Xi, Yi) (0 ≤ Xi ≤ 300; 0 ≤ Yi ≤ 300)。每颗流星都将摧毁落点及其相邻四点的区域。 Bessie在0时刻时处于原点,且只能行于第一象限,以平行与坐标轴每秒一个单位长度的速度奔走于未被毁坏的相邻(通常为4)点上。在某点被摧毁的刹那及其往后的时刻,她都无法进入该点。 寻找Bessie到达安全地点所需的最短时间。 Input - 输入 第1行: 一个整数: M 第2..M+1行: 第i+1行包含由空格分隔的三个整数: Xi, Yi, and Ti Output - 输出 仅一行: Bessie寻得安全点所花费的最短时间,无解则为-1。 Sample Input - 输入样例 4 0 0 2 2 1 2 1 1 2 0 3 5 Sample Output - 输出样例 5 AC代码: include include include include include using namespace std; int a

nginx多层反代配置变量proxy_set_header

妖精的绣舞 提交于 2019-11-28 11:17:49
Nginx多层反代配置变量proxy_set_header过程记录 第一层代理: (1)路径: $ vim /data/soft/nginx/conf/vhost/xixi.conf (2)内容:(注:此处变量名需中划线。) server { listen 80; server_name api.xxx.com api.yyyy.com api.cun.com; access_log /log/nginx/xiaojicdn.api.log main; root /data/www/pay/; location /member { proxy_intercept_errors on; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header real-remote $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://member.srv; } location /discount { proxy_intercept_errors on; proxy

POJ-2502(Dijikstra应用+最短路)

∥☆過路亽.° 提交于 2019-11-28 10:39:19
Subway POJ-2502 这里除了直接相连的地铁站,其他图上所有的点都要连线,这里是走路的速度。 记住最后的结果需要四舍五入,否则出错。 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> #include<vector> #include<queue> #include<cmath> #include<map> using namespace std; typedef pair<int,int> p; const int INF=0x3f3f3f3f; int sx,sy,ex,ey; struct edge{ int to; double cost; int next; }; struct node{ double dis; int to; node(){} node(int a,int b):dis(a),to(b){} bool operator<(const node& t)const{ return dis>t.dis; } }; edge ma[1500005]; int head[220]; int top;//指向头结点 double d[220]; int tn;//结点个数 int n=220;//最大结点数 map<pair

Meteor Shower POJ 3669(搜索)

半世苍凉 提交于 2019-11-28 06:12:27
原题 题目链接 题目分析 这道题难点在于怎么处理地图标记问题.可以这么处理,在每个格子里记录被流星砸的最早时间,如果这个格子不会被砸到则记为INF,然后跑bfs的时候加入一个参数来记录当前跑到第几步,也就是当前时间为多少,当当前时间now+1<要走格子的时间时(也就是下一步走到这个格子是安全的),就bfs下去,否则则不走,加这个判定后,当走到INF的格子的时候就可以结束了,当前时间就是答案. 代码 1 #include <iostream> 2 #include <algorithm> 3 #include <utility> 4 #include <cstdio> 5 #include <cmath> 6 #include <cstring> 7 #include <string> 8 #include <vector> 9 #include <stack> 10 #include <queue> 11 #include <map> 12 #include <set> 13 14 using namespace std; 15 const int INF=0x3f3f3f3f; 16 17 struct P 18 { 19 int x,y,t; 20 P (){} 21 P (int x_,int y_,int t_){x=x_,y=y_,t=t_;}; 22 }; 23 int

Curling 2.0 POJ 3009(搜索)

。_饼干妹妹 提交于 2019-11-28 06:10:38
原题 题目链接 题目分析 注意题目给的条件,石头到终点会终止.石头碰到冰块会停止,冰块消失.石头滑出边界,游戏失败.石头必须在10回合内到达终点否则游戏失败.按照这个条件写个dfs,记录一下深度就行了. 代码 1 #include <iostream> 2 #include <algorithm> 3 #include <utility> 4 #include <cstdio> 5 #include <cmath> 6 #include <cstring> 7 #include <string> 8 #include <vector> 9 #include <stack> 10 #include <queue> 11 #include <map> 12 #include <set> 13 14 using namespace std; 15 const int INF=0x3f3f3f3f; 16 17 int n,m; 18 int mapp[20][20]; 19 int dx[]={1,-1,0,0},dy[]={0,0,1,-1}; 20 int ans; 21 22 void dfs(int x,int y,int deep) 23 { 24 // printf("now x=%d y=%d\n",x,y); 25 if(deep==10) return ; 26 for

P1514-引水入城

两盒软妹~` 提交于 2019-11-28 04:54:23
1 #include <bits/stdc++.h> 2 #define _for(i,a,b) for(int i = (a);i < b;i ++) 3 #define _rep(i,a,b) for(int i = (a);i > b;i --) 4 #define INF 0x3f3f3f3f 5 typedef long long ll; 6 using namespace std; 7 inline ll read() 8 { 9 ll ans = 0; 10 char ch = getchar(), last = ' '; 11 while(!isdigit(ch)) last = ch, ch = getchar(); 12 while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar(); 13 if(last == '-') ans = -ans; 14 return ans; 15 } 16 inline void write(ll x) 17 { 18 if(x < 0) x = -x, putchar('-'); 19 if(x >= 10) write(x / 10); 20 putchar(x % 10 + '0'); 21 } 22 struct section

考后反思

試著忘記壹切 提交于 2019-11-27 19:19:54
好久没打反思了 博主过于弱于是分到第二机房 然而我在第二机房成绩也不行啊! 第一题这么个原题,然而我数组开小了,不多的几个没AC的 第二题看出来95分方法然而我打了然后我注释掉了???我为什么啊,考试时我想到链表会优化 我还打出来了 第三题再次看出正解 然而我最长链不会打,不会打你敢信 模板背不对报零两行泪 ll dp(ll x,ll pre){ if(f[x]) return f[x]; f[x]=0; for(ll i=head_[x];i;i=nxt_[i]){ ll y=ver_[i]; ll nx=dp(y,x); // printf("x=%d y=%d nx=%d\n",x,y,nx); f[x]=max(f[x],nx); } f[x]+=sz[x]; return f[x]; } 期望得分295 实际125. 挂的有点多 来源: https://www.cnblogs.com/znsbc-13/p/11373939.html