高效算法
BEconfidence
坚持才是胜利之道
展开
-
[极角排序 扫描法]UVa1606 - Amphiphilic Carbon Molecules
#include using namespace std; struct Node{ public : int x,y,z; double rad; bool operator < (const Node& rhs) const { return rad < rhs.rad; } }c[1000],d[1000]; bool Turn(Node&a,原创 2015-09-24 03:05:32 · 621 阅读 · 0 评论 -
[Hash思想]UVa1152 - 4 Values whose Sum is 0
#include using namespace std; struct HashMAP{ static const int mask = 0x7fffff; int p[8388608],q[8388608]; void Clear() { for(int i=0;i<=mask; ++ i) q[i]=0; } int& oper原创 2015-09-24 02:54:28 · 471 阅读 · 0 评论 -
[问题分解]UVa11054 - Wine trading in Gergovia
#include using namespace std; struct pp { int x1,x2,y1,y2,x,y,num; }B[5050]; bool cmp1(pp a,pp b) { if(a.x2==b.x2) return a.x1<b.x1; else return a.x2<b.x2; } bool cmp2(pp a,pp b) { if(a.y2==b.y2)原创 2015-09-24 02:58:35 · 447 阅读 · 0 评论 -
[等价转换]UVa11054 - Wine trading in Gergovia
第二个村庄的需求为a1+a2 #include using namespace std; int main() { int n; while(cin>>n&&n) { long long ans=0,a,last=0; for(int i=0; i<n; i++) { cin>>a;原创 2015-09-24 03:02:31 · 359 阅读 · 0 评论 -
[是用数据结构]UVa1471 - Defense Lines
#include using namespace std; #define inf 0x3f3f3f3f #define maxn 200000 int t,n,a[maxn],f[maxn],g[maxn],d[maxn],ans; int main() { scanf("%d",&t); while(t--){ scanf("%d",&n); f原创 2015-09-24 09:21:45 · 617 阅读 · 0 评论 -
[贪心]UVa11093 - Just Finish it up
#include using namespace std; typedef long long LL; const int MAXD=100000+10; int main() { int T,Case=1; int add[MAXD]; int next[MAXD]; int cost[MAXD]; scanf("%d",&T); while(T-原创 2015-09-24 09:54:43 · 594 阅读 · 0 评论