- 博客(15)
- 收藏
- 关注
原创 UVA 10305 Ordering Tasks
欧拉回路:每个节点走到最深再倒序输出 #include #include #include #include #include using namespace std; const int maxn=100+5; int G[maxn][maxn],topo[maxn]; int c[maxn],m,t; //保存状态; bool dfs(int u) { c[u]=-1; for(int
2016-04-27 21:23:24 598
原创 UVA 816 Abbott's Revenge
好复杂TAT 主要是BFS #include #include #include #include #include using namespace std; struct Node { int r,c,dir; Node(int r=0,int c=0,int dir=0) : r(r),c(c),dir(dir) {} }; const int maxn = 100; const c
2016-04-27 20:09:20 253
原创 UVa 572 Oil Deposits
遇到一个@就把相连的@全变成‘*’,再cnt++就好 #include #include #include using namespace std; char oil[105][105]; int m,n; void dfs(int i,int j); int main() { while(scanf("%d%d",&m,&n)&&m) { int cnt=0; memset(oil
2016-04-26 19:36:49 256
原创 D The Lucky Week
一开始是这么想的,七天七天加,保证每次都是星期一,每次遇到1,11,21就找到了 但N有10^9,肯定会超时。那么马上打表找规律,可就是找不出规律。 看了大神的,400年是一个周期,有2058个Lucky Week。找到规律后马上就AC了 #include #include #include using namespace std; int month[]={0,31,28,31,30,31
2016-04-25 20:28:24 392
原创 I People Counting
当时没想到,现在感觉思路打开就好了 思路:每次遇到一个部分就把身体其他部分一起变为一个不可能的符号并cnt++. 根据这个把相片从头到尾全部扫一遍就好。 #include #include using namespace std; int H,W,cnt; char photo[105][105]; const char m[3][4]={{"-O-"},{"/|\\"},{"(-)"}};
2016-04-24 20:47:43 337
原创 UVA 12096 The SetStack Computer
集合中不能有相同元素set_union,set_intersection 函数用前就应该保证输入两容器内有序且无重复 #include #include #include #include #include #include #include #include #define ALL(x) x.begin(),x.end() #define INS(x) insert
2016-04-19 15:58:28 608
原创 UVA 815 Flooded!
先sort一下,在计算出相邻高度差,再依次计算蓄水量 如案例中,13*100+2*200+7*300...... #include #include #include #include using namespace std; #define maxn 1000 int main() { int m,n,kase=0; while(scanf("%d%d",&m,&n)==2&&
2016-04-16 21:38:21 262
原创 UVa 1590 IP Networks
所有数转化为二进制放到数组里再一位一位比较,第一位出现不同位数后都为0 #include #include #include #include #include using namespace std; #define maxn 1005 int k; void ToB(int n,char *A) { stack S; int cnt=0; while(n) { S.pu
2016-04-16 20:18:45 307
原创 UVa 201 Squares
细节题,判断正方形比较麻烦,还有格式要注意,用时1h30min+ 考虑了两组数据结构存储 1.H[][]保存横排线,V[][]保存竖排线,判断正方形要x,y坐标换来换去,再加一加什么的 2.给每个点标号1~n^2 ,输入时处理一下数据用一个d[][]存储就好,判断正方形比前面这种稍微简单一点 我是用前者方法 #include #include #include #include
2016-04-11 18:15:51 343
原创 UVa 1589 Xiangqi
花了好长时间终于AC..... . 思路:将横竖看一看,再看看马,再上下左右走一走再判断一次 主要考虑特殊数据 马能不能走,还有将可以吃旁边的 2 1 4 H 2 2 H 2 6 4 2 5 R 3 5 G 10 4 C 5 5 R 2 9 #include #include #include #include using namespace
2016-04-10 21:38:52 409
原创 UVa 512 Spreadsheet Tracking
之前 #include #include #include using namespace std; #define maxn 100 struct command { char opt[5]; int a; int n[maxn]; int r1,r2,c1,c2; }cmd[maxn]; int k; int simulate(int& r0,int& c0); int mai
2016-04-10 18:39:03 493
原创 UVa 10340 All in All
#include #include #include #include #include using namespace std; int main() { string s; string t; while(cin>>s) { cin>>t; int slen=s.length(); int tlen=t.length(); int p=0,ok=0; for(in
2016-04-09 21:56:48 202
原创 UVa 202 Repeating Decimals
#include #include #include #include using namespace std; int main() { int a,b,c; while(cin>>a>>b) { c=a; int first=0,p=0,cnt=0,idx=0,i; char ans[200]={0}; ans[p++]=(a/b?a/b:0)+'0'; if(a){
2016-04-09 21:47:47 285
原创 中缀表达式转后缀并计算值
数字只能(0~9)运算符 加减乘除还有括号 #include #include #include #include #include #include #include using namespace std; #define maxn 100 void ToLast(string s,char* ans); double Value(char* ans); int main() { str
2016-04-09 21:36:31 314
原创 UVa 1588 Kickdown
#include #include #include #define maxn 105 using namespace std; int f(char *mas,char *dri); int main() { char mas[maxn]={0},dri[maxn]={0}; while(scanf("%s%s",mas,dri)!=EOF) { printf("%d\n"
2016-04-09 21:22:55 233
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人