2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02)
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)的更多相关文章
- 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, ...
- 2002-2003 ACM-ICPC Northeastern European Regional Contest (NEERC 02) A Amusing Numbers (数学)
其实挺简单的.先直接算出之前已经排在k这个数前面的数字.比如543是三位的,那么100~543都是可以的,两位的10~54. 如果还需要往前面补的话,那么依次考虑1000~5430,5430是上界不能 ...
- 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 个时刻 ...
- 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 ...
- 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 ...
- 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)C - Cactus Jubilee
题意:给一颗仙人掌,要求移动一条边,不能放在原处,移动之后还是一颗仙人掌的方案数(仙人掌:无向图,每条边只在一个环中),等价于先删除一条边,然后加一条边 题解:对于一颗仙人掌,分成两种边,1:环边:环 ...
- 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) 日常训练
A - Archery Tournament 题目大意:按时间顺序出现靶子和射击一个位置,靶子的圆心为(x, y)半径为r,即圆与x轴相切,靶子不会重叠,靶子被击中后消失, 每次射击找出哪个靶子被射中 ...
- 2015-2016 ACM-ICPC Northeastern European Regional Contest (NEERC 15)
NEERC 15 题解1 题解2 官方题解
- 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 ...
随机推荐
- jQuery获取动态添加的元素,live和on的区别
今天给大家说一下如果用jQuery获取动态添加的元素,通常如果你在网页上利用jQuery添加一个元素,那么用平常的jQuery获取元素的方法无效的获取不到的.可以用以下的方法获取动态元素!假设我们现在 ...
- manjaro中virtualbox(vbox)配置
一.更新源的配置: 1).自动方法: 在 终端 执行下面的arch" style="color: #002be5">命令从官方的源列表中对中国源进行测速和设置 su ...
- JAVA基础篇—异常
五种常见异常 1.NullPointerException 空指针 2.ClassNotFoundException 指定类不存在 3.ArithmeticException运算异常 4.ArrayI ...
- luogu2590 [ZJOI2008]树的统计
树剖裸题 #include <iostream> #include <cstdio> using namespace std; int n, uu, vv, hea[30005 ...
- luogu1251 餐巾计划问题
ss是源点,代表餐巾卖家,tt是汇点,代表记账收钱者. 记p(i)是i天早晨的可用毛巾数,q(i)是i天完了的废毛巾数. 建图见注释 #include <iostream> #includ ...
- iOS开发~CocoaPods安装和使用
随着 iOS 开发者的增多,业界也出现了为 iOS 程序提供依赖管理的工具,它的名字叫做:CocoaPods. CocoaPods项目的源码 在 Github 上管理.该项目开始于 2011 年 8 ...
- selenium - 下拉框操作
# 9. 下拉框操作# (1)等待下拉列表和下拉列表中值存在# (2)在下拉列表中选择一个值 # 三种方式# A. 获取所有的下拉列表值,然后用循环去匹配相同的值 select_by_index(下标 ...
- selenium - 常用页面操作
# 2.常用页面操作 # 访问某一个页面url = 'http://www.baidu.com'driver.get(url) # 获取页面的标题title = driver.titleprint(t ...
- [python学习篇][书籍学习][python standrad library][内建函数]之[all,any,basestring,isinstance,bin,bool,@classmethod,@staticmethod,cmp,enumerate
Python 解释器内置了一些函数,它们总是可用的.这里将它们按字母表顺序列出. Built-in Functions abs() divmod() input() open() st ...
- [python篇][1]configparser 问题汇总
https://wiki.python.org/moin/ConfigParserExamples 1 错误一 nicodeEncodeError: 'ascii' codec can't encod ...