随笔分类 -  unAccepted

1 2 下一页

WA UVa 10806 - Dijkstra, Dijkstra.
摘要:无向图,求从1出发到n再回到1的最短路,不能重复走同一条边。错误思路:先求出1到n的最短路,删去经过的边,再求一次最短路,相加,容易找到反例。WA# include <cstdio># include <cstring># include <queue># include <algorithm>using namespace std;# define N 100 + 5# define INF 0x3c3c3c3cint n, m;int pre[N], d[N];int w[N][N];void destory(void){ for (int 阅读全文

posted @ 2012-07-23 16:29 getgoing 阅读(320) 评论(0) 推荐(0)

COJ 1174 Shining Gems边界控制
摘要:这道题对枚举时限比较严,在写 check 函数时要注意边界不能超,因为超出边界有可能引用了上一组残留的数据,而使用 memset() 则会超时。# include <stdio.h># define N 1005# define DIR 4 const int dir[][2] = {{0,1}, {1,0}, {0,-1}, {-1,0}};int n, m;char b[N][N];char check(int i, int j){ char ch; int cnt, s; for (cnt = 1, s = i-2; s<i+2; ... 阅读全文

posted @ 2012-07-09 11:33 getgoing 阅读(198) 评论(0) 推荐(0)

[TLE] POJ 1730 Perfect Pth Powers
摘要:给出一个32位整型数 n,形如 n = x^p 的最大的 p;质因数分解;TLE,DISCUSS 中有的用枚举做的(要考虑浮点数精度问题),但是质因数分解应该也可以啊,为什么老是TLE?求大牛指点。# include <stdio.h># include <math.h>int gcd(int a, int b){return !b ? a:gcd(b, a%b);}int m;char t[60005];int p[10005];void solve(long long int n);void build_ptable(void);int main(){ long l 阅读全文

posted @ 2012-05-02 22:02 getgoing 阅读(257) 评论(0) 推荐(0)

WA:ZOJ 1025 Wooden Sticks
摘要:思路是:先对长乘以重量进行排序,除去完全相同的(l,w分别相等),然后依次计算dp(i),最后统计f[i] == 1的个数。为什么这样考虑呢?看图:为什么这样不对呢?看图:这就说明了统计1的个数的想法是错误的。看了网上的代码,都说是贪心。谁说WA的代码就没用? 1 # include <stdio.h> 2 # include <memory.h> 3 # include <stdlib.h> 4 5 typedef struct { 6 int l, w; 7 }stick; 8 9 int T, n;10 int mask[5002];11 int f[ 阅读全文

posted @ 2012-04-07 11:23 getgoing 阅读(326) 评论(0) 推荐(0)

WA: csu 1141节能
摘要:写着写着越来越觉得是dfs,dp写的不知道哪里出问题了。 1 # include <stdio.h> 2 # include <string.h> 3 4 # define INF 1<<30 5 # define MAXN 1002 6 7 # define MIN(x,y) ((x)<(y) ? (x):(y)) 8 9 int n, v;10 int p[MAXN];11 int d[MAXN];12 int vis[MAXN];13 long long int f[MAXN][MAXN]; /* 子问题f[i][j]:下一个关的是 i 或 j 阅读全文

posted @ 2012-04-05 11:16 getgoing 阅读(213) 评论(0) 推荐(0)

TLE:csu 1205 放石子游戏
摘要:表示第一次用dfs。。。 1 # include <stdio.h> 2 # include <string.h> 3 4 char board[1001][1001]; 5 char vis[1001]; 6 int trace[1001]; 7 int N, M, ans; 8 9 void dfs(int x, int y);10 void special_dfs(int x, int y, int trace[]);11 12 int main()13 {14 int i, j, x, y;15 16 while (~scanf("%d%d" 阅读全文

posted @ 2012-03-27 00:26 getgoing 阅读(243) 评论(0) 推荐(0)

TLE:csu 1016 最小公倍数
摘要:求删改方案总共多少种,预料之中的超时,因为所有提交的22次中有12次超时。 1 # include <stdio.h> 2 3 # define MAXN 205 4 5 int gcd(int a, int b); 6 7 int m[MAXN]; 8 int f[MAXN][MAXN]; 9 10 int main()11 {12 int i, j, T, n, lcm, tmp, cnt;13 14 scanf("%d", &T);15 while (T--)16 {17 cnt = 0;18 ... 阅读全文

posted @ 2012-03-21 01:25 getgoing 阅读(508) 评论(2) 推荐(1)

csu 1010 Water Drinking
摘要:并查集变种;# include <stdio.h># include <memory.h># define MAXN 100005int pre[MAXN];int dis[MAXN];int main(){ int n, x, y, i, mind, ans; while (~scanf("%d", &n)) { memset(dis, 0, sizeof(dis)); for (i = 0; i < MAXN; ++i) pre[i] = i; while (n--) { ... 阅读全文

posted @ 2012-03-20 23:04 getgoing 阅读(307) 评论(0) 推荐(0)

csu 1004 Xi and Bo
摘要:并查集;/* 下面的问题已经找到原因:dev c++使用c++编译器,变量end的命名可能出现冲突,使用gcc编译不会出现报错*/遇到了一个诡异的问题:全局变量放在main外报错。# include <stdio.h># define MAXN 105int father[MAXN];int main(){ int T, sta, end, n, m, x, y; int i; scanf("%d", &T); while (T--) { scanf("%d%d%d", &sta,&end,&n); f... 阅读全文

posted @ 2012-03-20 17:45 getgoing 阅读(613) 评论(3) 推荐(0)

WA: Product
摘要:和前面的高精度加法一样,实在找不到原因,之前的大数从来没这样的。。/* UVa 10106 - Product */# include <stdio.h># include <string.h># define MAXN 252char a[MAXN], b[MAXN];char ss[2 * MAXN];void pro(char *s);int main(){ int lena, lenb, i, j, tmp; while (~scanf("%s", a)) { scanf("%s", b); lena = str... 阅读全文

posted @ 2012-03-17 10:47 getgoing 阅读(226) 评论(0) 推荐(0)

Integer Inquiry
摘要:高精度加法,不知错在哪里。、 1 # include <stdio.h> 2 # include <string.h> 3 4 # define MAXN 110 5 6 char s[MAXN], sum[MAXN]; 7 8 int main() 9 {10 int i, len, c, tmp;11 char ch;12 13 while (scanf("%s", s) == 1)14 {15 len = strlen(s);16 17 if (len == 1 && s[0] == ... 阅读全文

posted @ 2012-03-16 23:40 getgoing 阅读(339) 评论(0) 推荐(0)

[noj 1002]囧:求最大值最小值 WA 8次
摘要:没有思考,直接按成法来,第一组数据都没通过。最关键的在于 if else 的结构没有考虑到如果输入的数都相等怎么办,另外如果输入的数是按增序排列也会得到错误的结果: 1 # include <stdio.h> 2 3 int main() 4 { 5 int x, N, min, max; 6 7 while (~scanf("%d", &N)) 8 { 9 max = 0;10 min = 100;11 while (N--)12 {13 sca... 阅读全文

posted @ 2012-03-13 14:37 getgoing 阅读(290) 评论(0) 推荐(0)

WA : csu1019 simple line editor
摘要:查了很多遍,不知道哪里错了,数组还不够大? 1 # include <stdio.h> 2 # include <ctype.h> 3 4 # define MAXN 10005 5 6 char a[MAXN]; 7 int i = -1, j, T; 8 char ch; 9 10 int main()11 {12 freopen("in.txt", "r", stdin);13 freopen("out.txt", "w", stdout);14 15 scanf("%d&q 阅读全文

posted @ 2012-03-12 15:23 getgoing 阅读(213) 评论(0) 推荐(0)

TLE: csu 1211 大整数开平方练习
摘要:模拟手工开方,必须使用大数,否则只用sqrt()即可。代码有点乱,结果应该是正确的,但是。。TLE了。。。接下来应该考虑把代码变短些,除去不必要的运算。要还是不行,怎么办啊。。。。欢迎各位大牛测试,谢谢指点!/* 大整数开方 */# include <stdio.h># include <string.h># include <stdlib.h># include <math.h># include <time.h># define MAXN 1001void bigN_sqrt(char *s);int bigN_cmp(char 阅读全文

posted @ 2012-03-03 17:19 getgoing 阅读(535) 评论(0) 推荐(0)

WA:csu1108 Flip Game
摘要:在POJ上提交用的是枚举,刚学了bfs各种混乱,WA了# include <stdio.h># include <string.h> # define MAX 65536 # define INDEX(i) ((i)>>3)# define OFFSET(i) ((i)%8) # define GET_BIT(i) (vis[INDEX(i)]>>OFFSET(i) & 0x1)# define SET_BIT(i) (vis[INDEX(i)] |= 0X1<<OFFSET(i)) char vis[INDEX(MAX)+1 阅读全文

posted @ 2012-02-29 11:59 getgoing 阅读(565) 评论(0) 推荐(0)

TLE csu 1236: 删数游戏
摘要:直接做,TLE:View Code /* csu 1236 */# include <stdio.h># include <string.h># define MAXN 2001void del(char *s, int len){ int i; i = 1; while (i < len && s[i-1]<=s[i]) ++i; while (i < len) { s[i-1] = s[i]; ++i; } s[i-1] = '\0';}int main(){ int len, i, S; c... 阅读全文

posted @ 2012-02-26 16:43 getgoing 阅读(282) 评论(0) 推荐(0)

csu 1233 病毒的复制
摘要:/* WA,对测试示例结果正确,不解 */已通过,原因是%I64d的使用不符合编译器的要求,百度了一下,这个问题早就有了……非常感谢Staginner大牛的帮助!变量定义输出方式gcc(mingw32)g++(mingw32)gcc(linux i386)g++(linux i386)MicrosoftVisual C++ 6.0long long“%lld”错误错误正确正确无法编译long long“%I64d”正确正确错误错误无法编译__int64“lld”错误错误无法编译无法编译错误__int64“%I64d”正确正确无法编译无法编译正确long longcout非C++正确非C++正确 阅读全文

posted @ 2012-02-25 00:39 getgoing 阅读(617) 评论(0) 推荐(0)

MLE: 找出出现偶数次的那个数
摘要:位标记,MLE了/* csu 1069 changelong MLE */# include <stdio.h># define MAX 10000000# define INDEX(x) ((x)>>(3))# define OFFSET(x) ((x)%(8))# define GET_BIT(x) (vis[INDEX(x)]>>OFFSET(x) & 0x1)# define SET_BIT(x) (vis[INDEX(x)] |= (char)((0x1)<<OFFSET(x)))char vis[INDEX(MAX)+1]; 阅读全文

posted @ 2012-02-24 09:32 getgoing 阅读(311) 评论(0) 推荐(0)

POJ 1002 487-3279
摘要:/* POJ 1002 487-3279*/# include <stdio.h># include <stdlib.h># include <ctype.h>typedef struct TeleNum{ int num; int rpt; struct TeleNum *next;} tel;const int h[] = {2,2,2,3,3,3, 4,4,4,5,5,5, 6,6,6,7,0,7,7, 8,8,8,9,9,9,0 };int ... 阅读全文

posted @ 2012-02-21 17:40 getgoing 阅读(176) 评论(0) 推荐(0)

zoj 2132 the most frequent number
摘要:the most frequent numberCE: Gcc注释 用/**/MLE: 快排 取中位数/*zoj 2132 the most frequent number quick sort */# include <stdio.h># include <stdlib.h># define MAXN 250005int compare (const void * a, const void * b){ return ( *(int*)a - *(int*)b );}int main(){ int a[MAXN]; int L, i; while (scanf(&qu 阅读全文

posted @ 2012-02-18 21:18 getgoing 阅读(300) 评论(0) 推荐(0)

1 2 下一页

导航