
POJ
KLFTESPACE
这个作者很懒,什么都没留下…
展开
-
Milk Patterns POJ - 3261
//sa[i]表示排名为i是从sa[i]位置开始的后缀//rank[i]表示起始位置的下标为i的后缀的排名// height[i]表示排名相邻的两个后缀的最长公共前缀长度//参考后缀数组(非常清楚)https://www.cnblogs.com/victorique/p/8480093.html//#include<bits/stdc++.h>#include&...原创 2019-09-26 22:48:53 · 148 阅读 · 0 评论 -
Network of Schools POJ - 1236
#include <string.h>#include<iostream>#include <stdio.h>const int V = 105; const int E = 1005;const int inf = 0x3f3f3f3f;using namespace std;struct edge { int to, next...原创 2019-07-18 18:58:45 · 147 阅读 · 0 评论 -
Shuffle'm Up POJ - 3087
感觉这道题可能有例外,比如都空的情况....,在string 类型里, 初始化时 用s21 += s12 会WA 然后 用s21 = s12就AC了....还有就是为什么要在刚开始给s21赋值呢..我是因为不初始化,就算s21[i]赋值了,,输出s21 仍然空....所以就试着赋了下值...就有结果了......#include<iostream>using namesp...原创 2019-07-07 12:50:03 · 124 阅读 · 0 评论 -
Balanced Lineup POJ-3264
模板题//RMQ的两种实现方法#include<cstdio>#include<iostream>#include<cmath>using namespace std;const int N=50010;int a[N], dpMax[N][30], dpMin[N][30];//查询数组a的[l,r]区间的最值int RMQ...原创 2019-05-06 21:10:08 · 273 阅读 · 0 评论 -
Mayor's posters POJ2528
喜欢他的离散化方法,但是,看别人的解释他的方法有问题就是131 101 46 10结果是2,但实际结果应该是3,解决方法得等我勤快起来才能写了.....转自https://blog.youkuaiyun.com/u013569304/article/details/51276536//线段树D #include<iostream>#i...转载 2019-04-24 17:53:08 · 180 阅读 · 0 评论 -
Ultra-QuickSort POJ - 2299 (树状数组求逆序对数)
//已修改#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int n;struct node{ int val, index;}a[500010];//最初的输入 int c[500010];//c[x]存储在区间 (...原创 2019-04-15 11:01:06 · 187 阅读 · 0 评论 -
Full Tank? POJ-3635
写这个,,主要是看到了用vector来模拟邻接表,就http://www.cnblogs.com/yimao/archive/2012/06/26/2563262.html的思路来了一遍#include<iostream>#include<cstdio>#include<vector>#include<queue>#inclu...原创 2019-03-18 17:37:22 · 277 阅读 · 0 评论 -
Crossing River POJ-1700
#include<iostream>#include<algorithm>using namespace std;int main(){ int T, n; cin >> T; while(T--){ cin >> n; int a[n+5]; int dp[n+5]; for(int i=1; i<=n; ...原创 2019-03-24 21:41:16 · 174 阅读 · 0 评论 -
A Simple Problem with Integers
//出现RE后,将数组大小开大,就好了。//把int改为long long 就由WA变为AC了//区间更新//参见 https://blog.youkuaiyun.com/SSL_ZYC/article/details/81940902 http://kenby.iteye.com/blog/962159#include<iostream>#include<cst...原创 2019-03-21 15:50:28 · 159 阅读 · 0 评论 -
Network POJ - 1861
#include<iostream>#include<cstdio>#include<queue>#include<cstring>using namespace std;const int N = 1e6+5;int n, m, Max;struct Edge{ int u, v, dist; Edge(){...原创 2019-03-03 09:21:36 · 214 阅读 · 0 评论 -
Truck History POJ - 1789
,,,原因是visited数组={0}开在了局部变量里.....但是还是不明白。。。。#include <iostream>#include <cstdio>#include <climits>const int N = 2000+25;char s[N][N];int m[N][N]={0};int n;using namespace ...原创 2019-03-03 09:13:11 · 184 阅读 · 0 评论 -
Constructing Roads POJ - 2421
//刚开始看错题了..看例子以为给你n行,每行意思为a, b之间的距离为dist.(有向).一直找不到自己错在哪 ,,, 然后....看了看别人的发现是无向....n*n位邻接矩阵.............#include<iostream>#include<cstdio>#include<queue>#include<cstring>...原创 2019-03-01 21:38:11 · 188 阅读 · 0 评论 -
Knight Moves BFS POJ 2488
//要注意清空队列(全局)或者写进函数里 #include <iostream>#include <cstdio>#include <queue>using namespace std;const int MAX = 8;int dirx[MAX] = {-2,-2,2,2,-1,-1,1,1}, diry[MAX] = {1,-1,-1,...原创 2019-02-23 20:05:09 · 161 阅读 · 0 评论 -
Fliptile POJ - 3279
//二进制枚举//遇到的问题就是在判断某点当前状态时,感觉可以不考虑当前位置的翻转,毕竟不会存在翻了一次又翻一次的状况....但是 当取消这一情况,就会WA。。。。后来发现是第一行初始化的时候,flip会取1.....所以....就需要考虑自身是否翻转了...#include<iostream>#include<cstdio>#include<cst...原创 2019-07-21 16:46:04 · 102 阅读 · 0 评论 -
Silver Cow Party POJ - 3268
/*每个点到指定点的距离+指定点回到各个点的距离*//*每指定点到每个点之间的逆序+指定点到每个点之间的正序*/ #include<iostream>#include<vector>#include<cstring>#include<algorithm>using namespace std;const int N = 1000...原创 2019-08-02 22:07:56 · 139 阅读 · 0 评论 -
Palindrome POJ - 3974
//AC版 #include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std ;string s, t;int len, MAX = 0;...原创 2019-09-14 20:53:01 · 117 阅读 · 0 评论 -
Longest Ordered Subsequence POJ - 2533
//就是直接拿的最少拦截系统 的代码 不过不能用万能头文件#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm> using namespace std;#define MAXN 40005i...原创 2019-09-07 22:23:32 · 117 阅读 · 0 评论 -
Blue Jeans POJ - 3080
#include<iostream>#include<cstdio>#include<string.h>#include<cmath>#include<cstdlib>using namespace std;const int N = 1e3+5;int nxt[N];int cnt = 0;string s[1...原创 2019-08-14 12:34:52 · 120 阅读 · 0 评论 -
Seek the Name, Seek the Fame POJ - 2752
//刚开始数组开的太大了1e6,OLE了,, 后来看错了开的太小4*1e4...RE.。。。后来发现题目要求4*1e5.。。AC//字符串s的前next[i]长度的字符和后next[i]长度的字符是相同的#include<iostream>#include<cstdio>#include<cstring>#include<cmath&g...原创 2019-08-13 22:46:21 · 121 阅读 · 0 评论 -
Power Strings POJ - 2406
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>using namespace std;const int N = 1e6+5;int nxt[N];int cnt = 0;char s1[N],...原创 2019-08-13 20:50:12 · 100 阅读 · 0 评论 -
The Unique MST POJ - 1679
算次小生成树模板吧,prim的话。。。应该就是更新MAX数组的时候,不是直接=,语句是MAX[u][v] = MAX[v][u] = max(MAX[pre[u]][v], dis[u]);//dis[u] = MAX[u][pre[u]]//心累....第一次拿map做标记,然后,,就遇到问题了,,,拿样例二就会发现,计入map的大小不对....然后,就会发现,由于first是Edge,...原创 2019-08-06 17:12:46 · 143 阅读 · 0 评论 -
spfa和迪杰斯特拉(邻接表)
这个算spfa模板吧...本来想用来解Til the Cows Come Home POJ - 2387 ,但是。。有重边....所以。用邻接表的话..重边问题我暂时不知道怎么解决...只能用邻接矩阵做了..然后 这个就用作spfa模板吧感觉。。。如果用队列的话,迪杰斯特拉和spfa之间应该就是vis[]用处不同了....毕竟,spfa可以判断负回环#include <i...原创 2019-07-31 20:58:12 · 286 阅读 · 0 评论 -
Prime Path POJ - 3126
//判断条件写错了,导致没结果,然后就是最高位不能为0,否则会导致结果出错....Both numbers are four-digit primes (without leading zeros)....../*思路:因为要找最少变换素数次数,所以,用bfs解,每次每位由0-9选择,存入队列,直到符合最终结果,此时步数为最短步数*/#include<iostream>...原创 2019-07-23 09:04:32 · 131 阅读 · 0 评论 -
Networking POJ - 1287
#include<iostream>#include<cstdio>#include<queue>#include<cstring>using namespace std;const int N = 1000+5;struct Edge{ int u, v, dist; Edge(){ u = 0...原创 2019-08-04 21:22:04 · 172 阅读 · 0 评论 -
Jungle Roads POJ - 1251
#include<iostream>#include<cstdio>#include<queue>#include<cstring>using namespace std;const int N = 1000+5;struct Edge{ int u, v, dist; Edge(){ u = 0...原创 2019-08-04 21:16:41 · 164 阅读 · 0 评论 -
Currency Exchange POJ - 1860
不标记,直至起始位置的dis大于初始即为YES,还有一种做法是判断某一点的遍历次数是否大于n,若大于n,即为有回环#include <iostream>#include <cstdio>#include <cstring>#include <queue>#include <stack>#include <vec...原创 2019-08-03 17:40:49 · 147 阅读 · 0 评论 -
Find The Multiple POJ - 1426
//7.9做的....但是当时RE了,就不想在调试了....今天重看了下,发现输入少了个条件,即不为0#include<iostream>#include<cstdio>#include<cmath>using namespace std;typedef unsigned long long LL;bool flag;void dfs(L...原创 2019-07-21 19:18:28 · 119 阅读 · 0 评论 -
Wireless Network POJ - 2236
//读取C的时候没有!=EOF 会出现TLE的错误..... #include<iostream>#include<cstdio>#include<algorithm>using namespace std;const int N = 10000+5;pair<int, int> a[N];int pre[N], store[...原创 2019-02-18 12:03:01 · 134 阅读 · 0 评论 -
Catch That Cow POJ - 3278
/* * * *想用结构体做下,结果一直RE,1 40000,不会有结果。用数组做了就AC了....待解决 #include<iostream>#include<cstdlib>#include<queue>#include<string.h>#include<cstdio>using namespace std...原创 2019-02-16 12:17:09 · 150 阅读 · 0 评论 -
Symmetric Order POJ - 2013 ZOJ 2172
In your job at Albatross Circus Management (yes, it's run by a bunch of clowns), you have just finished writing a program whose output is a list of names in nondescending order by length (so that e...原创 2018-10-11 08:22:07 · 233 阅读 · 0 评论 -
The 3n + 1 problem POJ - 1207 UVA3470
Pascal University, one of the oldest in the country, needs to renovate its Library Building, because after all these centuries the building started to show the effects of supporting the weight of the ...原创 2018-10-08 21:04:01 · 190 阅读 · 0 评论 -
The 3n + 1 problem POJ - 1207 UVA100
Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose ...原创 2018-10-08 21:04:16 · 223 阅读 · 0 评论 -
Gold Coins POJ - 2000 ZOJ2345 UVA 3045
The king pays his loyal knight in gold coins. On the first day of his service, the knight receives one gold coin. On each of the next two days (the second and third days of service), the knight receiv...原创 2018-10-01 10:47:31 · 280 阅读 · 0 评论 -
Self Numbers POJ - 1316 ZOJ 1180 UVA640
In 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any positive integer n, define d(n) to be n plus the sum of the digits of n. (The d stands for dig...原创 2018-10-01 10:37:50 · 235 阅读 · 0 评论 -
Speed Limit POJ - 2017 ZOJ2229
Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately, Bill has a working stopwatch, so they can record their sp...原创 2018-10-01 10:19:18 · 202 阅读 · 0 评论 -
Vertical Histogram POJ - 2136(PE 找不到错在哪了...)
Write a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text input (no more than 72 characters per line) from the input file and print a vertical histogram that shows how many tim...原创 2018-10-01 10:19:31 · 195 阅读 · 0 评论 -
POJ2943 UVALive3524 The Cow Doctor【bitset+枚举】
转自 海岛Blog转这篇文章主要是对19行的代码有点不明白,因为本人调试的代码,bitset不赋初值则位上的数都为0, 但是,把该段删除后WA,不明白。/* POJ2943 UVALive3524 The Cow Doctor */ #include <iostream>#include <bitset>#include <math.h> ...转载 2018-08-01 21:05:23 · 251 阅读 · 0 评论 -
Perfection
From the article Number Theory in the 1994 Microsoft Encarta: ``If a, b, c are integers such that a = bc, a is called a multiple of b or of c, and b or c is called a divisor or factor of a. If c is no...原创 2018-05-31 11:55:31 · 459 阅读 · 0 评论 -
I Think I Need a Houseboat POJ - 1005, ZOJ 1049, UVA 2363
Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land, he learned that the state of Louisiana is actually shrinking by 50 square ...原创 2018-05-09 22:12:23 · 308 阅读 · 0 评论 -
Sum of Consecutive Prime Numbers POJ 2739, UVA 3399
Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example, the integer 53 has two repre...原创 2018-05-09 21:20:46 · 269 阅读 · 0 评论