B Bricks 计算几何乱搞

题意:

给你个立方体,问你能不能放进一个管道里面。

题解:

这是一道非常迷的题,其问题在于,你可以不正着放下去,你需要斜着放。此时你需要枚举你旋转的角度,来判断是否可行。至于枚举的范围和步长,看脸乱搞。

代码:

//#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<fstream>
using namespace std; long double x[],y[]; const long double pi=acos(-); long double a,b;
long double d,e; const long double eps=1e-; int main() {
ifstream cin("bricks.in");
ofstream cout("bricks.out");
cin.sync_with_stdio(false);
cin >> x[] >> x[] >> x[] >> y[] >> y[];
sort(x, x + );
sort(y, y + );
a = x[], b = x[];
d = y[], e = y[];
if (d - a > -eps && e - b > -eps) {
cout << "YES" << endl;
return ;
}
long double dd = pi / ( * (3e6));
for (long double t = acos(e / b); t < asin(d / b) + dd; t += dd) {
if (min((e - b * cos(t)) / sin(t), (d - b * sin(t)) / cos(t)) > a - eps) {
cout << "YES" << endl;
return ;
}
}
cout << "NO" << endl;
return ;
}

E Evacuation Plan 最小费用流

题意:

题目好长好长好长。。。。。简单说就是,发生核战争了,人们要避难,给你每个建筑的坐标,给你每个避难所的坐标,每个建筑里面有若干人,从一个建筑到一个避难所的时间,是坐标的曼哈顿距离,现在要你使总时间花费最少。

题解:

就最小费用的模板题。最后在残余网络上寻找解即可。

代码:

//#include <iostream>
#include<vector>
#include<fstream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string>
#include<cmath>
#define MAX_V 222
#define INF 1008611
using namespace std;
struct edge {
public:
int to, cap, cost, rev;
bool isRev; edge(int t, int c, int co, int re,bool ir) : to(t), cap(c), cost(co), rev(re),isRev(ir) { } edge() { }
};
int V=;
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V]; void add_edge(int from,int to,int cap,int cost) {
G[from].push_back(edge(to,cap,cost,G[to].size(),));
G[to].push_back(edge(from,,-cost,G[from].size()-,));
} char cc;
int min_cost_flow(int s,int t,int f) {
int res = ;
while (f > ) {
fill(dist, dist + V, INF);
dist[s] = ;
bool update = ;
while (update) {
update = ;
for (int v = ; v < V; v++) {
if (dist[v] == INF)continue;
for (int i = ; i < G[v].size(); i++) {
edge &e = G[v][i];
if (e.cap > && dist[e.to] > dist[v] + e.cost) {
//cout<<"*"<<endl;
dist[e.to] = dist[v] + e.cost;
prevv[e.to] = v;
preve[e.to] = i;
update = ;
}
}
}
}
if (dist[t] == INF)
return -; int d = f;
for (int v = t; v != s; v = prevv[v])
d = min(d, G[prevv[v]][preve[v]].cap);
f -= d;
res += d * dist[t];
for (int v = t; v != s; v = prevv[v]) {
edge &e = G[prevv[v]][preve[v]];
e.cap -= d;
G[v][e.rev].cap += d;
}
}
return res;
} int n,m; struct build {
public:
int x, y,c; build(int xx, int yy,int cc) : x(xx), y(yy), c(cc){ } build() { } int dis(build a){
return abs(a.x-x)+abs(a.y-y)+;
}
}; typedef build shelter; build bu[MAX_V];
shelter sh[MAX_V]; int plan;
int S=; int main() {
ifstream cin("evacuate.in");
ofstream cout("evacuate.out");
cin.sync_with_stdio(false);
cin >> n >> m;
for (int i = ; i < n; i++) {
cin >> bu[i].x >> bu[i].y >> bu[i].c;
S += bu[i].c;
}
for (int i = ; i < m; i++)
cin >> sh[i].x >> sh[i].y >> sh[i].c;
for (int i = ; i < n; i++)
for (int j = ; j < m; j++) {
int k;
cin >> k;
plan += k * bu[i].dis(sh[j]);
}
for (int i = ; i < n; i++)
add_edge(n + m, i, bu[i].c, );
for (int j = ; j < m; j++)
add_edge(j + n, n + m + , sh[j].c, );
for (int i = ; i < n; i++)
for (int j = ; j < m; j++)
add_edge(i, j + n, INF, bu[i].dis(sh[j]));
V = n + m + ;
int tmp = min_cost_flow(n + m, n + m + , S);
if (tmp == plan) {
cout << "OPTIMAL" << endl;
return ;
}
cout << "SUBOPTIMAL" << endl;
for (int i = ; i < n; i++, cout << endl)
for (int j = ; j < G[i].size(); j++)
if (!G[i][j].isRev)
cout << INF - G[i][j].cap << " "; return ;
}

I Inlay Cutters 模拟+图论

题意:

给你一个棋盘,现在切若干刀,问你最后有几个三角形。

题解:

由于三个点在平面上只能构成三角形,那么此题可以转化为图论问题来解决,将相邻的直线交点连边,然后在图上求有多少个三元环即可。

代码:

//#include<iostream>
#include<fstream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#define MAX_N 10004
using namespace std; int N,M,K; int d[]; struct knife {
public:
int from, to, dir; knife(int f, int t, int d) : from(f), to(t), dir(d) { } knife() { }
}; knife kn[MAX_N]; int cnt[MAX_N]; vector<int> G[MAX_N]; int main() {
ifstream cin("inlay.in");
ofstream cout("inlay.out");
cin.sync_with_stdio(false);
cin >> M >> N >> K;
d[] = * M + ;
d[] = ;
d[] = M + ;
d[] = M;
for (int i = ; i < K; i++) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (y1 > y2 || (y1 == y2 && x1 > x2)) {
swap(x1, x2);
swap(y1, y2);
}
int u = x1 * d[] + y1 * d[];
int v = x2 * d[] + y2 * d[];
int t;
if (x1 == x2)t = ;
else if (y1 == y2)t = ;
else if (x2 > x1)t = ;
else t = ;
kn[i] = knife(u, v, t);
}
kn[K++] = knife(, M, );
kn[K++] = knife(N * d[], N * d[] + M * d[], );
kn[K++] = knife(, N * d[], );
kn[K++] = knife(M, N * d[] + M, );
for (int i = ; i < K; i++) {
int u = kn[i].from, v = kn[i].to, t = kn[i].dir;
while (u != v) {
cnt[u]++;
u += d[t];
}
cnt[v]++;
}
int V = -;
for (int i = ; i < K; i++) {
int u = kn[i].from, v = kn[i].to, t = kn[i].dir;
int p = u;
while (u != v) {
u += d[t];
if (cnt[u] > ) {
V = max(V, u);
V = max(V, p);
G[p].push_back(u);
G[u].push_back(p);
p = u;
}
}
}
int ans = ;
V++;
for (int u = ; u < V; u++)
sort(G[u].begin(), G[u].end());
for (int u = ; u < V; u++)
for (auto v:G[u])
for (auto c:G[v]) {
if (c == u)continue;
int t = lower_bound(G[c].begin(), G[c].end(), u) - G[c].begin();
if (G[c][t] == u)ans++;
//cout<<c<<" "<<u<<" "<<v<<endl;
}
cout << ans/ << endl;
return ;
}

2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02)的更多相关文章

  1. 2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02) H Heroes Of Might And Magic (隐含dp)

    问题是求一个方案,实际隐含一个dp.法力是递减的,所以状态是DAG,对于一个确定的状态,我们贪心地希望英雄的血量尽量大. 分析:定义状态dp[i][p][h]表示是已经用了i的法力值,怪兽的位置在p, ...

  2. 2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02) A Amusing Numbers (数学)

    其实挺简单的.先直接算出之前已经排在k这个数前面的数字.比如543是三位的,那么100~543都是可以的,两位的10~54. 如果还需要往前面补的话,那么依次考虑1000~5430,5430是上界不能 ...

  3. 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17)

    2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) A 题意:有 n 个时刻 ...

  4. Editing 2011-2012 ACM-ICPC Northeastern European Regional Contest (NEERC 11)

    NEERC 11 *wiki链接[[https://acm.ecnu.edu.cn/wiki/index.php?title=2011-2012_ACM-ICPC_Northeastern_Europ ...

  5. 2012-2013 ACM-ICPC Northeastern European Regional Contest (NEERC 12)

    Problems     # Name     A Addictive Bubbles1 addictive.in / addictive.out 2 s, 256 MB    x438 B Blin ...

  6. 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)C - Cactus Jubilee

    题意:给一颗仙人掌,要求移动一条边,不能放在原处,移动之后还是一颗仙人掌的方案数(仙人掌:无向图,每条边只在一个环中),等价于先删除一条边,然后加一条边 题解:对于一颗仙人掌,分成两种边,1:环边:环 ...

  7. 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) 日常训练

    A - Archery Tournament 题目大意:按时间顺序出现靶子和射击一个位置,靶子的圆心为(x, y)半径为r,即圆与x轴相切,靶子不会重叠,靶子被击中后消失, 每次射击找出哪个靶子被射中 ...

  8. 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)

    NEERC 15 题解1 题解2 官方题解

  9. ACM ICPC 2010–2011, Northeastern European Regional Contest St Petersburg – Barnaul – Tashkent – Tbilisi, November 24, 2010

    ACM ICPC 2010–2011, Northeastern European Regional Contest St Petersburg – Barnaul – Tashkent – Tbil ...

随机推荐

  1. Yii2.0 的安装学习

    视频学习地址: 后盾网视频: http://www.houdunren.com/houdunren18_lesson_76?vid=7350 与<Yii框架>不得不说的故事—基础篇 htt ...

  2. poj-1011 sticks(搜索题)

    George took sticks of the same length and cut them randomly until all parts became at most 50 units ...

  3. 网络流之Dinic算法

    初学网络流.存一下Dinic板子. 复杂度O(n^2*m) UVA - 1515 Pool construction 把每个草地与 S 相连,花费为dig,每个洞与 T 相连,花费为 然后对于每个两个 ...

  4. Root CA certificate:ApacheJMeterTemporaryRootCA.crt created in JMeter bin directory

    今天学习jmeter录制,在点击start之后弹出: 且在jmeter安装目录里确实生成了ApacheJMeterTemporaryRootCA.crt文件 上网查询官方文档http://120.52 ...

  5. UVa 10934 DP Dropping water balloons

    首先想一下特殊情况,如果只有一个气球,我们要确定高度只能从下往上一层一层地测试,因为如果气球一旦爆了,便无法测出气球的硬度. 如果气球有无数个,那么就可以用二分的方法来确定. 一般地,用d(i, j) ...

  6. 设计模式之单例模式 Singleton实现

    饿汉式 饿汉式单例模式,static变量会在类装载时初始化,此时也不会涉及多个线程对象访问该对象的问题.虚拟机保证只会装载一次该类,肯定不会发生并发访问的问题, 因此可以省略synchronized关 ...

  7. Zookeeper在windows环境下安装

    1.已安装JDK并配置好了环境变量 2.下载Zookeeper,在清华大学镜像下载,选择合适版本  https://mirrors.tuna.tsinghua.edu.cn/apache/zookee ...

  8. 第3章 jquery中的事件和动画

    一,jquery中的事件 (1).执行时机 $(document).ready()和window.onload方法有相似的功能,但是在执行时机方面有区别,windwo.onload在网页中所有的元素包 ...

  9. PHPStorm.WebStrom等系列官方开发工具配置本地项目与运程服务器同步

    PHPStorm.WebStrom配置本地项目与运程服务器同步 说明:PHPStorm.WebStrom等官方的系统开发工具配置本地项目与运程服务器同步的方法都基本一致没有,几乎没有什么不同之处,我们 ...

  10. BZOJ 2733 [HNOI2012]永无乡 ——线段树 并查集

    用并查集维护联通块. 用线段树的合并来合并联通块. 自己YY了一个写法. #include <map> #include <cmath> #include <queue& ...