WA题集
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
+ ;
struct points
{
double x,y;
};
points point[MAX];
double d[MAX][MAX];
double dist(int a, int b)
{
return sqrt( (point[a].x - point[b].x) * (point[a].x - point[b].x) + (point[a].y - point[b].y) * (point[a].y - point[b].y));
}
int main()
{
int n;
while(scanf("%d", &n) != EOF)
{
; i <= n; i++)
scanf("%lf%lf", &point[i].x, &point[i].y);
; i < n - ; i++)
d[n - ][i] = dist(n - , n) + dist(i, n);
; i > ; i--)
{
; j < i; j++)
{
][j] + dist(i, i + ) - d[i + ][i] - dist(j, i + ) > 0.00001)
d[i][j] = d[i + ][j] + dist(i, i + );
else
d[i][j] = d[i + ][i] + dist(j, i + );
}
}
printf(][] + dist(,));
}
;
}
UVA1347紫书dp
zoj1163http://blog.csdn.net/cherry_sun/article/details/6245208
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cstdio>
using namespace std;
map<string,int> color;
][],cnt[],sum[];
+ ];
int main()
{
int n,m;
while(scanf("%d%d", &n, &m) != EOF)
{
&& m == )
break;
];
; i <= n; i++)
{
scanf("%s", temp);
color[temp] = i;
}
int x;
memset(cnt, , sizeof(cnt));
memset(sum, , sizeof(sum));
memset(ans, , sizeof(ans));
; i <= m; i++)
{
scanf("%d%s",&x, temp);
cloth[ color[temp] ][ cnt[ color[temp] ]++ ] = x;
}
; i <= n; i++)
{
; j < cnt[i]; j++)
{
sum[i] += cloth[i][j];
}
}
;
; i <= n; i++)
{
;
; j < cnt[i]; j++)
{
for(int k = v; k >= cloth[i][j]; k--)
{
ans[k] = max(ans[k], ans[k - cloth[i][j]] + cloth[i][j]);
}
}
all += sum[i] - ans[v];
}
printf("%d\n",all);
}
;
}
UVA类似于8皇后问题
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
;
int g[MAX][MAX],vis[MAX][MAX*MAX];
int n,m,ans,t;
void dfs(int x,int cnt)
{
;
for(int i = x; i < n; i++)
{
; j < m; j++)
{
if(g[i][j])
{
][j] == && vis[][i + j] == && vis[][i - j + t] == )
{
flag = ;
break;
}
}
}
)
{
break;
}
}
)
{
ans =min(ans,cnt);
return ;
}
; i < m; i++)
{
if(g[x][i])
{
][i] == && vis[][x + i] == && vis[][x - i + t] == )
{
vis[][i] = vis[][x + i] = vis[][x - i + t] = ;
dfs(x + , cnt + );
vis[][i] = vis[][x + i] = vis[][x - i + t] = ;
}
}
}
}
int main()
{
;
while(scanf("%d", &n) != EOF)
{
)
break;
scanf("%d", &m);
t = max(n,m);
getchar();
memset(vis,,sizeof(vis));
memset(g,,sizeof(g));
char ch;
; i < n; i++)
{
; j < m; j++)
{
scanf("%c",&ch);
if(ch == 'X')
g[i][j] = ;
}
getchar();
}
ans = ;
dfs(,);
printf("Case %d: %d\n",num++,ans);
}
;
}
POJ 3026 Borg Maze
http://poj.org/problem?id=3026
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
typedef pair<int,int> P;
;
][];
][],vis[][],dis[][],edge[][];
int t,row,col,num;
][]={{,},{,},{,-},{-,} };
void bfs(int x,int y)
{
queue<P> q;
P point;
point.first = x;
point.second = y;
memset(vis,,sizeof(vis));
memset(dis,,sizeof(dis));
vis[x][y] = ;
q.push(point);
while(q.size())
{
P temp;
temp = q.front();
q.pop();
if( node[temp.first][temp.second] )
{
// cout<<node[x][y] <<" "<<node[point.first][point.second]<<endl;
edge[ node[x][y] ][ node[temp.first][temp.second] ] = dis[temp.first][temp.second];
}
; i < ; i++)
{
];
];
&& fy >= && fx < row && fy < col)
{
&& g[fx][fy] != '#')
{
dis[fx][fy] = dis[temp.first][temp.second] + ;
vis[fx][fy] = ;
point.first = fx;
point.second = fy;
q.push(point);
}
}
}
}
}
void prime()
{
];
];
; i < num; i++)
{
v[i] = false;
}
; i < num; i++)
s[i] = edge[][i];
v[] = true;
;
; i < num; i++)
{
int pos, minn = INF;
; j < num; j++)
{
if(v[j] == false && s[j] < minn)
{
minn = s[j];
pos = j;
}
}
sum += minn;
v[pos] = true;
; j < num; j++)
{
if(s[j] > edge[pos][j])
s[j] = edge[pos][j];
}
}
printf("%d\n",sum);
}
int main()
{
scanf("%d", &t);
while(t--)
{
scanf("%d%d", &col,&row);
getchar();
num = ;
memset(node,,sizeof(node));
memset(edge,,sizeof(edge));
; i < row; i ++)
{
; j < col; j++)
{
scanf("%c", &g[i][j]);
if(g[i][j] == 'A' || g[i][j] == 'S')
node[i][j] = num++;
}
getchar();
}
; i < row; i++)
{
; j < col; j++)
if(node[i][j])
bfs(i,j);
}
prime();
}
;
}
POJ2253
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
+ ;
<< ;
struct Node
{
int x,y;
};
Node point[MAX];
int N;
double path[MAX][MAX],dist[MAX],ans;
int vis[MAX];
void prime()
{
memset(vis,,sizeof(vis));
; i <= N; i++)
dist[i] = path[][i];
vis[] = ;
dist[] = ;
;
; i < N; i++)
{
double minn = INF;
; j <= N; j++)
{
&& dist[j] < minn)
{
minn = dist[j];
pos = j;
}
}
vis[pos] = ;
dist[pos] = minn;
)
return;
if(ans < minn)
ans = minn;
; j <= N; j++)
{
)
dist[j] = dist[pos] + path[pos][j];
}
}
}
int main()
{
;
while(scanf("%d", &N) != EOF && N)
{
; i <= N; i++)
{
scanf("%d%d",&point[i].x,&point[i].y);
}
; i <= N; i++)
{
; j <= N; j++)
{
double x = point[i].x - point[j].x;
double y = point[i].y - point[j].y;
path[i][j] = sqrt(x * x + y * y);
}
}
ans = ;
prime();
printf("Scenario #%d\n",++t);
if(ans)
printf("Frog Distance = %0.3lf\n",ans);
else
printf(][]);
printf("\n");
}
;
}
WA题集的更多相关文章
- 数位dp题集
题集见大佬博客 不要62 入门题,检验刚才自己有没有看懂 注意一些细节. 的确挺套路的 #include<bits/stdc++.h> #define REP(i, a, b) for(r ...
- ACM题集以及各种总结大全!
ACM题集以及各种总结大全! 虽然退役了,但是整理一下,供小弟小妹们以后切题方便一些,但由于近来考试太多,顾退役总结延迟一段时间再写!先写一下各种分类和题集,欢迎各位大牛路过指正. 一.ACM入门 关 ...
- 全国各大 oj 分类题集...
各种题集从易到难刷到手软 你准备好了吗? 准备剁手吧
- ACM题集以及各种总结大全(转)
ACM题集以及各种总结大全! 虽然退役了,但是整理一下,供小弟小妹们以后切题方便一些,但由于近来考试太多,顾退役总结延迟一段时间再写!先写一下各种分类和题集,欢迎各位大牛路过指正. 一.ACM入门 关 ...
- 组合数取模&&Lucas定理题集
题集链接: https://cn.vjudge.net/contest/231988 解题之前请先了解组合数取模和Lucas定理 A : FZU-2020 输出组合数C(n, m) mod p (1 ...
- Bug是一种财富-------研发同学的错题集、测试同学的遗漏用例集
此文已由作者王晓明授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 各位看官,可能看到标题的你一定认为这是一篇涉嫌"炒作"的文章,亦或是为了吸引眼球而起的标 ...
- 二级C语言题集
时间:2015-5-13 18:01 在131题之后是按考点分类的题集,有需要的朋友可以看一下 ---------------------------------------------------- ...
- 中南大学2019年ACM寒假集训前期训练题集(基础题)
先写一部分,持续到更新完. A: 寒衣调 Description 男从戎,女守家.一夜,狼烟四起,男战死沙场.从此一道黄泉,两地离别.最后,女终于在等待中老去逝去.逝去的最后是换尽一生等到的相逢和团圆 ...
- 【转】并查集&MST题集
转自:http://blog.csdn.net/shahdza/article/details/7779230 [HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基 ...
随机推荐
- 基于React,Redux以及wilddog的聊天室简单实现
本文主要是使用ReactJs和Redux来实现一个聊天功能的页面,页面极其简单.使用React时间不长,还是个noob,有不对之处欢迎大家吐槽指正. 还要指出这里没有使用到websocket等技术来实 ...
- 在View and Data API中更改指定元素的颜色
大家在使用View and Data API开发过程中,经常会用到的就是改变某些元素的颜色已区别显示.比如根据某些属性做不同颜色的专题显示,或者用不同颜色表示施工进度,或者只是简单的以颜色变化来提醒用 ...
- Linux2.6内核进程调度系列--scheduler_tick()函数2.更新实时进程的时间片
RT /** * 递减当前进程的时间片计数器,并检查是否已经用完时间片. * 由于进程的调度类型不同,函数所执行的操作也有很大差别. */ /* 如果是实时进程,就进一步根据是FIFO还是RR类型的实 ...
- iOS 10 开发适配系列 之 权限Crash问题
升级 iOS 10 之后目测坑还是挺多的,记录一下吧,看看到时候会不会成为一个系列. 直入正题吧 今天用一个项目小小练下手,发现调用相机,崩了.试试看调用相册,又特么崩了.然后看到控制台输出了以下信息 ...
- vim使用笔记
vim的配置文件.vimrc 一般有2个位置 1是在/目录下 2是在-目录下 如果在-目录下有了配置文件 那么将不去读取/目录下面的配置文件 如果你不知道现在使用的vim 使用的是哪个目录下面的配置 ...
- 用Retrofit发送请求中添加身份验证
用Retrofit发送请求中添加身份验证====================在安卓应用开发中, retrofit可以极大的方便发送http网络请求,不管是GET, POST, 还是PUT, DEL ...
- WPF 自定义DateControl DateTime控件
自定义日期控件,月份选择.如下是日期的一些效果图. 具体的样式.颜色可以根据下面的代码,自己调节即可 1.日期控件的界面 <UserControl x:Class="WpfApp ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- [No000092]SVN学习笔记3-Import/Checkout(迁入/迁出),GetLock(加锁)
一.TortoiseSVN Client 获取服务器端的文件到新的本地文件夹 1.在本地新文件夹上右键菜单: 2.打开Repo-browser(可能需要输入你的用户名&密码) 3.输入服务器端 ...
- [LeetCode] Integer to English Words 整数转为英文单词
Convert a non-negative integer to its english words representation. Given input is guaranteed to be ...