zoj 3432 Find the Lost Sock(zoj月赛,受打击了 = =)
2010-11-14 17:43
357 查看
详见
http://blog.sina.com.cn/s/blog_677a3eb30100mjy9.html
终于有解题报告了 = =
一直TLE。
我尝试了N种方法,包括我最讨厌的链表 = =,它就是TLE,我哭。
而且学会了个用scanf输入字符串(包括空格的)
scanf("%[^/n]",str);
后来实在过不去,就尝试,看哪种读入数据方法好。
gets() < scanf("%[^/n]",str) < scanf("%c",&str[0]) 第三个是最慢的,一个字符一个字符读入。
上面的解题报告我好佩服啊,位运算!!总是被我忽略 = =。。
就是啊 异或运算,算到最后,留下的,肯定是没有匹配到的。。。强大。。
我就贴个我的链表 TLE的吧。。。
http://blog.sina.com.cn/s/blog_677a3eb30100mjy9.html
终于有解题报告了 = =
一直TLE。
我尝试了N种方法,包括我最讨厌的链表 = =,它就是TLE,我哭。
而且学会了个用scanf输入字符串(包括空格的)
scanf("%[^/n]",str);
后来实在过不去,就尝试,看哪种读入数据方法好。
gets() < scanf("%[^/n]",str) < scanf("%c",&str[0]) 第三个是最慢的,一个字符一个字符读入。
上面的解题报告我好佩服啊,位运算!!总是被我忽略 = =。。
就是啊 异或运算,算到最后,留下的,肯定是没有匹配到的。。。强大。。
我就贴个我的链表 TLE的吧。。。
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <string.h> using namespace std; typedef struct NODE { char str[10]; struct NODE *next; }NODE; NODE s,temp[3000000]; int main(void) { int n; char ss[10]; while( scanf("%d",&n)!= EOF ) { getchar(); memset(temp,0,sizeof(temp)); temp[0].str[0] = 'a'; s = temp[0]; for(int i=1; i<=2*n-1; i++) { gets(temp[i].str); int flag = 0; NODE *p = &s; while( p->next != NULL ) { if( strcmp(p->next->str,temp[i].str) == 0 ) { flag = 1; p -> next = p->next -> next; break; } else p = p->next; } if( flag == 0 ) { NODE *aa = &temp[i]; p->next = aa; } } NODE *pp = &s; puts(pp->next->str); } return 0; }
相关文章推荐
- ZOJ 3432 Find the Lost Sock
- ZOJ 3432 Find the Lost Sock(模拟)
- zoj 3432 Find the Lost Sock(解决时间超时问题)
- zoj 3432 Find the Lost Sock
- zoj3432——Find the Lost Sock
- ZOJ 3432 Find the Lost Sock (异或的运用)
- ZOJ 3432 Find the Lost Sock
- ZOJ 3432 Find the Lost Sock
- ZOJ 3432 Find the Lost Sock 解题报告
- zoj 3432 Find the Lost Sock
- 异或解题:Find the Lost Sock
- zoj3432 Find the Lost Sock 亦或的运用
- 1416: Find the Lost Sock
- ZCMU-1416-Find the Lost Sock
- ZOJ3432 Find the Lost Sock(异或运算)
- ZOJ3432 Find the Lost Sock,异或运算
- zoj 3605 Find the Marble (概率dp)
- Find the Marble ZOJ - 3605 概率dp
- zoj 3605 Find the Marble 计数dp
- ZOJ 3605 Find the Marble