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. Linux中让alias设置永久生效的方法详解

    Linux中让alias设置永久生效的方法详解 一.问题描述 1.有很多时候我们想要将很多操作作为一个步骤,那么在不作为系统的服务的情况下,别名是我们最好的选择,但是发现别名只能在一次会话中生效,重启 ...

  2. Python学习笔记:wxPython(GUI图形用户界面)

    wxPython是一套基于Python的第三方GUI插件,可用Python制作丰富的图形化界面程序. 安装:pip install wxPython 或者 网站下载安装https://pypi.org ...

  3. 探讨2018年最受欢迎的15顶级Python库!

    近日,数据科学网站 KDnuggets 评选出了顶级 Python 库 Top15,领域横跨数据科学.数据可视化.深度学习和机器学习.如果本文有哪些遗漏,你可以在评论区补充. 图 1:根据 GitHu ...

  4. Java获得字节码对象的三种方式

    1.Class 类的forName方法 Class clazz = Class.forName("com.test.Test"); 该方法要注意的是会抛出一个ClassNotFou ...

  5. VSCode编译C/C++(一)MinGW安装配置指南

    为什么不用IDE? 更加专业.轻便.其过程对于理解计算机也有更多的帮助 安装过程: 首先进入http://mingw.org/  ,点击右侧最新发布,可以下载,然后安装 点击桌面MinGWInstal ...

  6. csapp-15213错误修正18-10-28

    1.p229 练习题3.15 b.答案错误,应为400419

  7. Centos 7下利用crontab定时执行任务详解

    一 cron服务 cron服务是Linux的内置服务,但它不会开机自动启动.可以用以下命令启动和停止服务: /sbin/service crond start /sbin/service crond ...

  8. luogu1242 新汉诺塔

    就是一步一步把大的往目标地放. #include <iostream> #include <cstdio> using namespace std; int fro[55], ...

  9. 04-python进阶-map&reduce

    Map --映射 Reduce -- 归纳 将大数据标准化的处理 Map 拆封任务,Reduce将结果合并 这样是不是能够将很多计算机组成一台超级计算机呢? 一些问题:如果任务本身就很复杂,那么拆解任 ...

  10. [python学习篇][书籍学习][python standrad library][内置类型]对象测试真值,布尔值操作, 比较操作

    几乎所有对象都可以比较.测试真值.转换为字符串(其实就是用repr()函数,或略有差异的str()函数来转换) 1 对象是否为真 任何对象都可以测试真值,用于if或while的条件或下面布尔运算的操作 ...