2017 ACM/ICPC Asia Regional Guangxi Online 记录
题目链接 Guangxi
感觉这场比赛完全是读题场啊……
比赛过程中丢失了一波进度,最后想开题的时候已经来不及了……
Problem A
按题意模拟……按照那个矩阵算就可以了
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i)
#define dec(i, a, b) for (int i(a); i >= (b); --i) double a[10][10];
int b[100010];
char s[100010]; int main(){ rep(i, 1, 4) rep(j, 1, 4) cin >> a[i][j];
getchar();
fgets(s, 100010, stdin);
int len = strlen(s); int n = 0;
rep(i, 0, len - 1){
if (s[i] >= '0' && s[i] <= '9'){
++n;
b[n] = s[i] - 48;
}
} double gg = 1.0000000; rep(i, 1, n - 1) gg = gg * a[b[i]][b[i + 1]]; printf("%.8f\n", gg);
fgets(s, 100010, stdin);
len = strlen(s); n = 0;
rep(i, 0, len - 1){
if (s[i] >= '0' && s[i] <= '9'){
++n;
b[n] = s[i] - 48;
}
} gg = 1.0000000; rep(i, 1, n - 1) gg = gg * a[b[i]][b[i + 1]]; printf("%.8f\n", gg); int kk;
scanf("%d", &kk);
gg = 1.00 / (1 - a[kk][kk]); printf("%.8f\n", gg); scanf("%d", &kk);
gg = 1.00 / (1 - a[kk][kk]); printf("%.8f\n", gg);
return 0;
}
Problem C
这道题限制条件比较多,比赛的最后一分钟才通过
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i)
#define dec(i, a, b) for (int i(a); i >= (b); --i)
#define MP make_pair
#define fi first
#define se second typedef long long LL;
typedef pair <int, int> PII; const int N = 2010000; vector <PII > a; int n, m;
int ans[N];
int q; bool cmp(PII a, PII b){
return a.fi == b.fi ? a.se < b.se : a.fi > b.fi;
} int main(){ scanf("%d%d", &n, &m);
rep(i, 1, n){
a.clear();
int x;
scanf("%d", &x);
int xx, yy;
int cnt = 0;
while (true){
scanf("%d", &xx);
if (xx == -1) break;
scanf("%d", &yy);
if (yy < x) continue;
++cnt;
a.push_back({yy, xx});
} if (cnt == 0) continue;
sort(a.begin(), a.end(), cmp); int uu = a[0].se;
int hhhh = 0;
if (cnt == 1) hhhh = x; else hhhh = a[1].fi;
int tt = hhhh * 1.1000;
int ff = min(tt, a[0].fi);
ans[uu] += (int)ff;
} scanf("%d", &q);
while (q--){
int k;
scanf("%d", &k);
printf("%d\n", ans[k]);
} return 0;
}
Problem F
求矩形面积并 模板题
#include <bits/stdc++.h> using namespace std; #define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1 typedef long long LL; const LL N = 1e5 + 10; int n;
struct Seg {
double l, r, h;
LL d;
Seg() {}
Seg(double l, double r, double h, LL d): l(l), r(r), h(h), d(d) {}
bool operator< (const Seg& rhs) const {return h < rhs.h;}
} a[N]; LL cnt[N << 2];
LL sum[N << 2], all[N]; void push_up(LL l, LL r, LL rt){
if (cnt[rt]) sum[rt] = all[r + 1] - all[l];
else if(l == r) sum[rt] = 0; //leaves have no sons
else sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
} void update(LL L, LL R, LL v, LL l, LL r, LL rt) {
if(L <= l && r <= R) {
cnt[rt] += v;
push_up(l, r, rt);
return;
}
LL m = l + r >> 1;
if(L <= m) update(L, R, v, lson);
if(R > m) update(L, R, v, rson);
push_up(l, r, rt);
} int main() { while (~scanf("%d", &n)){
if (n == 0){ putchar('*'); break;}
for(LL i = 1; i <= n; ++i) {
LL x1, y1, x2, y2;
scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
a[i] = Seg(x1, x2, y1, 1);
a[i + n] = Seg(x1, x2, y2, -1);
all[i] = x1; all[i + n] = x2;
}
n <<= 1;
sort(a + 1, a + 1 + n);
sort(all + 1, all + 1 + n);
LL m = unique(all + 1, all + 1 + n) - all - 1; memset(cnt, 0, sizeof cnt);
memset(sum, 0, sizeof sum); LL ans = 0;
for(LL i = 1; i < n; ++i) {
LL l = lower_bound(all + 1, all + 1 + m, a[i].l) - all;
LL r = lower_bound(all + 1, all + 1 + m, a[i].r) - all;
if(l < r) update(l, r - 1, a[i].d, 1, m, 1);
ans += sum[1] * (a[i + 1].h - a[i].h);
}
printf("%lld\n", ans);
}
return 0;
}
Problem G
推出勾股定理的公式之后直接迭代一波
迭代的时候减掉的那个值忘记*2 WA2小时
=。=
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i)
#define dec(i, a, b) for (int i(a); i >= (b); --i)
#define MP make_pair
#define fi first
#define se second typedef long long LL;
typedef double ld; ld r;
int k;
int l; ld sqr(ld x){ return x * x;} ld calc(ld r, int k){
ld ret;
ld now = (sqrt(3.00) - 1.00) * r;
rep(i, 1, k){
ret = (now * now) / (2 * now + 2 * r);
now -= ret * 2;
} return ret;
} int main(){ while (~scanf("%d", &l)){
if (l == -1) break;
cin >> r;
rep(i, 1, l){
cin >> k;
double yy = calc(r, k);
printf("%d %d\n", k, (int)(yy));
}
} return 0;
}
Problem L
水DP 树状数组维护
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i <= (b); ++i)
#define dec(i, a, b) for (int i(a); i >= (b); --i)
#define MP make_pair
#define fi first
#define se second typedef long long LL; const int N = 2e5 + 10; int va[N], w[N], b[N];
int n, x;
int c[N], f[N]; inline void update(int x, int val){
for (; x <= n; x += x & -x) c[x] = max(c[x], val);
} inline int query(int x){
int ret = 0;
for (; x; x -= x & -x) ret = max(ret, c[x]);
return ret;
} int main(){ while (~scanf("%d", &x)){
++n;
if (x >= 10000) va[n] = x - 10000;
else va[n] = x;
if (x < 0) w[n] = 0; else if (x >= 10000) w[n] = 5; else w[n] = 1;
} rep(i, 1, n) b[i] = va[i];
sort(b + 1, b + n + 1);
int cnt = unique(b + 1, b + n + 1) - b - 1;
rep(i, 1, n) va[i] = lower_bound(b + 1, b + cnt + 1, va[i]) - b; memset(c, 0, sizeof c);
rep(i, 1, n){
f[i] = query(va[i]) + w[i];
update(va[i], f[i]);
} int ans = 0;
rep(i, 1, n) ans = max(ans, f[i]);
printf("%d\n", ans);
return 0;
}
2017 ACM/ICPC Asia Regional Guangxi Online 记录的更多相关文章
- 2017 ACM/ICPC Asia Regional Beijing Online 记录
题目链接 Beijing
- 2017 ACM/ICPC Asia Regional Xian Online 记录
题目链接 Xian
- 2017 ACM/ICPC Asia Regional Qingdao Online 记录
题目链接 Qingdao Problem C AC自动机还不会,暂时暴力水过. #include <bits/stdc++.h> using namespace std; #define ...
- 2017 ACM/ICPC Asia Regional Urumuqi Online 记录
比赛题目链接 Urumuqi
- 2017 ACM/ICPC Asia Regional Shenyang Online 记录
这场比赛全程心态爆炸…… 开场脑子秀逗签到题WA了一发.之后0贡献. 前期状态全无 H题想复杂了,写了好久样例过不去. 然后这题还是队友过的…… 后期心态炸裂,A题后缀数组理解不深,无法特判k = 1 ...
- 2017 ACM ICPC Asia Regional - Daejeon
2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...
- 2017 ACM/ICPC Asia Regional Shenyang Online spfa+最长路
transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/1 ...
- 2017 ACM/ICPC Asia Regional Qingdao Online
Apple Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submi ...
- HDU - 6215 2017 ACM/ICPC Asia Regional Qingdao Online J - Brute Force Sorting
Brute Force Sorting Time Limit: 1 Sec Memory Limit: 128 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...
随机推荐
- 【Qt】2.1 创建对话框
QDialog是Qt对话框类,可以直接使用这个类来创建对象并显示出来. 要使用一个对话框,就这样子写: #include <QApplication> #include <QDial ...
- LeetCode || 双指针 / 单调栈
11. Container With Most Water 题意:取两根求最大体积 思路:使用两个指针分别指向头和尾,然后考虑左右两根: 对于小的那根,如果选择了它,那么能够产生的最大体积一定是当前的 ...
- 8 Java 归并排序(MergerSort)
图片素材与文字描述来自:尚硅谷-韩顺平数据结构与算法. 1.基本思想 归并排序是利用归并的思想实现的排序方法,该算法采用经典的分治(divide-and-conquer)策略(分治法将问题分(divi ...
- javascript中typeof、undefined 和 null
typeof 是运算符,注意不是函数,是运算符,其作用,是考察变量究竟是什么类型.或曰,是变量是否定义或是否初始化的照妖镜.返回值是字符串. undefined 表示一个对象没有被定义或者没有被初始化 ...
- [LUOGU] 1717 钓鱼
题目描述 话说发源于小朋友精心设计的游戏被电脑组的童鞋们藐杀之后非常不爽,为了表示安慰和鼓励,VIP999决定请他吃一次"年年大丰收",为了表示诚意,他还决定亲自去钓鱼,但是,因为 ...
- OpenWrt 路由器如何让 lan 口主机获得 ipv6 网络访问 -- 知乎
本文转自知乎: OpenWrt 路由器如何让 lan 口主机获得 ipv6 网络访问? - mistforest的回答 - 知乎https://www.zhihu.com/question/29667 ...
- perl学习之文件测试
用Open() 函数打开文件 打开文件的常用方法是: open(FH, "< $filename") or die "Couldn't open $filename ...
- 解决zend studio代码无法自动提示的3个方法
最近电脑重装,索性把用了好多年的老版本7.x 升级了,网上下载了一个12.x的破解版. 起初一切正常,等导入项目开始开发的时候发现PHP函数尽然没有提示,一脸懵逼! 经过多方查阅和尝试,现在分享3个解 ...
- SQLServer数据库查看死锁、堵塞情况
在压力测试过程中,不间断的按F5键执行上面的SQL语句,如果出现死锁或者堵塞现象,就会在执行结果中罗列出来.如果每次连续执行SQL,都有死锁或者堵塞出现,说明死锁或者堵塞的比较严重. --每秒死锁数量 ...
- Hive中文注释乱码解决方案
本文来自网易云社区 作者:王潘安 快速解决方法 目前的hive客户端在执行desc tablexxx和show create table xxx命令的时候,字段的中文注释会出现乱码情况,如(????) ...