
POJ
kkjy_00
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ3263 Tallest Cow
#include<iostream> #include<cstdio> #include<cstring> #include<map> #include<utility> using namespace std; int a[10010], b[10010]; map<pair<int,int>,bool> ex原创 2018-07-24 17:54:04 · 245 阅读 · 0 评论 -
POJ3190 Stall Reservations
贪心+优先队列 引用他人的题解:将奶牛按照挤奶开始的时间进行升序排序,再用一个小顶堆维护每一个畜栏当前的挤奶结束时间。对于当前的奶牛,如果所有畜栏最小的结束时间都大于它的开始时间,则新开一个畜栏,将结束时间设为当前奶牛的结束时间,加入优先队列;如果能够用结束时间最小的畜栏了,则将该畜栏的结束时间更新为当前奶牛的结束时间。 来源:https://www.cnblogs.com/iiyiyi/p/...原创 2019-02-13 17:23:37 · 128 阅读 · 0 评论 -
POJ1789 Truck History
最小生成树(kruskal) #include<cstdio> #include<algorithm> using namespace std; const int maxn = 2e3 + 5; char s[maxn][8]; int prt[maxn], n, cnt; struct node { int u, v, w; bool operato...原创 2019-02-25 16:16:20 · 90 阅读 · 0 评论 -
POJ2485 Highways
最小生成树(kruskal) #include<cstdio> #include<algorithm> using namespace std; const int maxn = 505; int prt[maxn], n; struct node { int u, v, w; bool operator < (const node &b)...原创 2019-02-25 16:49:56 · 179 阅读 · 0 评论 -
POJ1258 Agri-Net
最小生成树(kruskal) #include<cstdio> #include<algorithm> using namespace std; const int maxn = 105; int prt[maxn], n; struct node { int u, v, w; bool operator < (const node &b)...原创 2019-02-25 17:03:13 · 87 阅读 · 0 评论 -
POJ2159 Ancient Cipher
具体怎么替换和置换都不知道,所以只需要确保频率一样即可 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; char s1[105], s2[105]; int len, a[105], b[105]; int check1(char c) { int...原创 2019-02-25 20:19:35 · 143 阅读 · 0 评论 -
POJ1007 DNA Sorting
归并排序求逆序对 #include<cstdio> #include<algorithm> using namespace std; int cnt; struct node { char s[55], c[55]; int num, id; bool operator < (const node &b) const{ ...原创 2019-02-25 21:56:46 · 93 阅读 · 0 评论 -
POJ2388 Who's in the Middle
很简单的一道题目 排序,输出中位数即可 #include<cstdio> #include<algorithm> using namespace std; const int maxn = 1e4 + 5; int a[maxn]; void quicksort(int head,int tail) { int i = head, j = tail, k = ...原创 2019-02-20 16:47:17 · 216 阅读 · 0 评论 -
POJ1035 Spell checker
就是一道暴力题 开数组时一万开成了一千,一直报错,想了好久才发现,>﹏< #include<cstdio> #include<cstring> using namespace std; char dic[10005][20], check[55][20]; int cnt = 0, num = 0; void solve(int i) { for(int j ...原创 2019-02-20 20:07:21 · 170 阅读 · 0 评论 -
POJ2387 Til the Cows Come Home
前向星+堆优化dijkstra #include<cstdio> #include<queue> #include<cstring> #include<utility> using namespace std; const int maxn = 4e3 + 5; int ver[maxn], edge[maxn], next[maxn], hea...原创 2019-02-27 08:50:22 · 107 阅读 · 0 评论 -
POJ3259 Wormholes
spfa判断负环 题意:John的农场里N块地,M条路连接两块地,W个虫洞,虫洞是一条单向路,会在你离开之前把你传送到目的地,就是当你过去的时候时间会倒退Ts。我们的任务是知道会不会在从某块地出发后又回来,看到了离开之前的自己。总的来说,就是看图中有没有负权环。有的话就是可以,没有的话就是不可以了。(题意来源:https://www.cnblogs.com/lienus/p/4273501.ht...原创 2019-02-27 09:46:47 · 101 阅读 · 0 评论 -
POJ3279 Fliptile
二进制搜索 开关问题 第一次碰到利用二进制表示状态的题目,利用二进制每一位上的0或1代表黑白。思路来自网上的一些大佬。 #include<cstdio> #include<cstring> using namespace std; int a[20][20], tmp[20][20], ans[20][20], res, n, m; int next[][2] = {...转载 2019-03-30 17:25:31 · 131 阅读 · 0 评论 -
POJ2893 M × N Puzzle
对于该类问题,根据列数判断,若列数为奇数,根据奇数码问题,计算当前逆序对个数与初始逆序对个数奇偶性是否相同,若为偶数,根据偶数码问题,计算当前逆序对个数加上两状态空格的行数之差的奇偶性与初始状态是否相同 求逆序对用归并排序 #include<cstdio> using namespace std; const int maxn = 1e6 + 5; int a[maxn], b[...原创 2019-02-13 16:35:39 · 212 阅读 · 0 评论 -
POJ2182 Lost Cows
树状数组+二分 将数组初始化为1,二分查找前缀和,前缀和代表有多少个数比当前位置小 #include<cstdio> using namespace std; const int maxn = 8e3 + 5; int a[maxn], b[maxn], n, ans[maxn]; int lowbit(int x){return x&(-x);} void update...原创 2019-02-17 16:58:59 · 178 阅读 · 0 评论 -
POJ2299 Ultra-QuickSort
归并排序求逆序对 用long long存结果 #include<cstdio> using namespace std; const int maxn = 5e5 + 5; int a[maxn], b[maxn]; long long cnt; void Merge(int l,int mid,int r) { int k = l, j = mid+1; for(...原创 2019-02-11 17:04:06 · 225 阅读 · 0 评论 -
POJ2018 Best Cow Fences
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; double a[100005], b[100005], sum[100005]; int main() { int N, L; scanf("%d%d",&N,&L); memset(s...原创 2018-07-28 15:26:36 · 348 阅读 · 0 评论 -
POJ1050 To the Max
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define maxn 105 #define inf 0x3f3f3f3f int a[maxn][maxn], dp[maxn][maxn][maxn]; int main() { int n; sc...原创 2018-07-27 17:30:45 · 114 阅读 · 0 评论 -
POJ3614 Sunscreen
贪心 #include<cstdio> #include<algorithm> #define maxn 2505 using namespace std; struct node{ int a, b; }; node cow[maxn], spf[maxn]; bool cmp(node m,node n){ if(m.a != n.a) return m.a &...原创 2018-08-01 09:56:11 · 111 阅读 · 0 评论 -
POJ2689 Prime Distance
用线性筛打出质数,在打标记 引用: 首先我们发现:R-LR−L 的范围很小,我们应该要能够快速求出 L\sim RL∼R 之间的质数。 显然有推论:任意一个合数 xx 必定包含一个不超过 \sqrt xx 的质因子。 所以我们可以筛出 [1,\sqrt R][1,R] 之间的所有质数,对于每个质数 pp,把 [L,R][L,R] 中能被 pp 整除的数标记为合数。最终没有被标记的数就是...原创 2019-01-21 15:38:59 · 149 阅读 · 0 评论 -
POJ1995 Raising Modulo Numbers
快速幂的简单题目 Time 94ms Memory 88kB #include<cstdio> using namespace std; int quickpow(int a,int b,int p) { int ans = 1; while(b){ if(b & 1) ans = (long long)ans * a %...原创 2019-01-22 11:24:59 · 130 阅读 · 0 评论 -
POJ3468 A Simple Problem with Integers
线段树的题目,照着书上敲了一遍 #include<cstdio> #include<cstring> using namespace std; const int maxn = 1e5 + 5; int num[maxn]; struct node { int l, r, add; long long sum; node() { ...原创 2019-02-01 18:44:21 · 127 阅读 · 0 评论 -
POJ1456 Supermarket
贪心+并查集 将利润大的尽可能往后安排,尽可能多的卖出商品,用并查集维护一个一维数组记录位置的变化表示该日是否有商品 #include<cstdio> #include<algorithm> using namespace std; const int maxn = 1e4 + 5; int prt[maxn]; struct node { int p, d;...原创 2019-02-16 15:59:25 · 189 阅读 · 0 评论 -
POJ1733 Parity game
带权并查集 思路来自lyd大佬的书 #include<cstdio> #include<algorithm> using namespace std; const int maxn = 1e4 + 5; int prt[maxn], d[maxn], a[maxn]; struct node { int l, r, ans; } query[maxn]; in...原创 2019-02-16 17:36:03 · 92 阅读 · 0 评论 -
POJ1182 食物链
扩展域并查集 分为同类域,捕食域,天敌域 #include<cstdio> using namespace std; const int maxn = 5e4 + 5; int prt[3*maxn]; int getpa(int x) { return x == prt[x] ? x : prt[x] = getpa(prt[x]); } int main() { ...原创 2019-02-16 19:11:40 · 100 阅读 · 0 评论 -
POJ1845 Sumdiv
首先要知道所有因子和的公式,然后分治 #include<cstdio> #include<cmath> using namespace std; const int mod = 9901; long long ans; long long quickpow(long long x,long long y) { long long res = 1; whi...原创 2019-02-11 15:39:41 · 118 阅读 · 0 评论 -
POJ3784 Running Median
动态维护中位数 对顶堆 #include<cstdio> #include<queue> using namespace std; const int maxn = 1e4; int a[maxn]; priority_queue<int,vector<int>,greater<int> > smallheap; priority_q...原创 2019-02-11 16:17:06 · 158 阅读 · 0 评论 -
POJ2104 K-th Number
主席树静态模板 #include<cstdio> #include<algorithm> using namespace std; const int maxn = 1e5 + 5; int a[maxn], b[maxn], T[maxn], tot; struct node{ int l, r, sum; } tree[maxn*20]; void init() {...原创 2019-05-01 10:01:47 · 219 阅读 · 0 评论