solved 4/11

2016 Multi-University Training Contest 8

贪心 1001 Ball(BH)

代码:

#include <bits/stdc++.h>

const int N = 1000 + 5;
std::pair<int, int> a[N];
int n, m; int main() {
int T;
scanf ("%d", &T);
while (T--) {
scanf ("%d%d", &n, &m);
for (int i=1; i<=n; ++i) {
int c;
scanf ("%d", &c);
a[i] = {0, c};
}
for (int i=1; i<=n; ++i) {
int c;
scanf ("%d", &c);
for (int j=1; j<=n; ++j) {
if (a[j].second == c && !a[j].first) {
a[j].first = i;
break;
}
}
}
while (m--) {
int l, r;
scanf ("%d%d", &l, &r);
std::sort (a+l, a+r+1);
}
bool flag = true;
for (int i=1; i<=n; ++i) {
if (a[i].first != i) {
flag = false;
break;
}
}
puts (flag ? "Yes" : "No");
}
return 0;
}

物理+微分方程 1006 physics(BH)

代码:

#include <bits/stdc++.h>

int v[100005];

int main() {
int T;
scanf ("%d", &T);
while (T--) {
int n, c;
scanf ("%d%d", &n, &c);
for (int i=1; i<=n; ++i) {
int x, d;
scanf ("%d%d%d", v+i, &x, &d);
}
std::sort (v+1, v+1+n);
int m;
scanf ("%d", &m);
while (m--) {
int t, k;
scanf ("%d%d", &t, &k);
printf ("%.3f\n", sqrt ((double) v[k]*v[k] + 2.0*c*t));
}
}
return 0;
}

线段树+优化 1008 Rikka with Sequence(BH)

代码:(数据加强后TLE)

#include <bits/stdc++.h>

typedef long long ll;
const int N = 1e5 + 5; #define lch o << 1
#define rch o << 1 | 1 ll sum[N<<2], same[N<<2], add[N<<2]; void push_up(int o) {
if (same[lch] == same[rch])
same[o] = same[lch];
else
same[o] = 0;
sum[o] = sum[lch] + sum[rch];
} void push_down1(int o, int l, int r) {
add[lch] += add[o];
add[rch] += add[o];
int mid = l + r >> 1;
sum[lch] += add[o] * (mid-l+1);
sum[rch] += add[o] * (r-mid);
if (same[lch])
same[lch] += add[o];
if (same[rch])
same[rch] += add[o];
add[o] = 0;
} void push_down2(int o, int l, int r) {
same[lch] = same[rch] = same[o];
int mid = l + r >> 1;
sum[lch] = same[o] * (mid-l+1);
sum[rch] = same[o] * (r-mid);
same[o] = 0;
} void build(int o, int l, int r) {
add[o] = 0;
if (l == r) {
scanf ("%I64d", &sum[o]);
same[o] = sum[o];
return ;
}
int mid = l + r >> 1;
build (lch, l, mid);
build (rch, mid+1, r);
push_up (o);
} void modify_add(int o, int l, int r, int ql, int qr, int c) {
if (ql <= l && r <= qr) {
sum[o] += (ll) (r - l + 1) * c;
if (same[o])
same[o] += c;
else
add[o] += c;
return ;
}
if (add[o])
push_down1 (o, l, r);
if (same[o])
push_down2 (o, l, r);
int mid = l + r >> 1;
if (ql <= mid)
modify_add (lch, l, mid, ql, qr, c);
if (qr > mid)
modify_add (rch, mid+1, r, ql, qr, c);
push_up (o);
} void modify_sqrt(int o, int l, int r, int ql, int qr) {
if (ql <= l && r <= qr && same[o]) {
same[o] = (ll) sqrt ((double) same[o]);
sum[o] = same[o] * (r - l + 1);
add[o] = 0;
return ;
}
if (add[o])
push_down1 (o, l, r);
if (same[o])
push_down2 (o, l, r);
int mid = l + r >> 1;
if (ql <= mid)
modify_sqrt (lch, l, mid, ql, qr);
if (qr > mid)
modify_sqrt (rch, mid+1, r, ql, qr);
push_up (o);
} ll query(int o, int l, int r, int ql, int qr) {
if (ql <= l && r <= qr) {
return sum[o];
}
if (add[o])
push_down1 (o, l, r);
if (same[o])
push_down2 (o, l, r);
int mid = l + r >> 1;
ll ret = 0;
if (ql <= mid)
ret += query (lch, l, mid, ql, qr);
if (qr > mid)
ret += query (rch, mid+1, r, ql, qr);
return ret;
} int main() {
int T;
scanf ("%d", &T);
while (T--) {
int n, m;
scanf ("%d%d", &n, &m);
build (1, 1, n);
int tp, ql, qr, c;
while (m--) {
scanf ("%d%d%d", &tp, &ql, &qr);
if (tp == 1) {
scanf ("%d", &c);
modify_add (1, 1, n, ql, qr, c);
} else if (tp == 2) {
modify_sqrt (1, 1, n, ql, qr);
} else {
printf ("%I64d\n", query (1, 1, n, ql, qr));
}
}
}
return 0;
}

构造 1011 Rikka with Parenthesis II(BH)

代码:

#include <bits/stdc++.h>

const int N = 1e5 + 5;
char str[N];
int n; bool check() {
if (n & 1)
return false; if (n == 2) {
if (strcmp (str, ")(") != 0)
return false;
} int l = 0, r = 0;
for (int i=0; i<n; ++i) {
if (str[i] == '(')
l++;
else
r++;
}
return l == r;
} int main() {
//freopen ("1011.txt", "r", stdin);
int T;
scanf ("%d", &T);
while (T--) {
scanf ("%d", &n);
scanf ("%s", str); //printf ("%s ", str); if (!check ()) {
puts ("No");
continue;
} int top = 0, error = 0, id = -1;
for (int i=0; i<n; ++i) {
if (str[i] == '(') {
top++;
} else {
if (top == 0) {
error++;
id = i;
break;
}
else
top--;
}
} if (!error) {
puts (top == 0 ? "Yes" : "No");
} else {
str[id] = '(';
top = error = 0;
for (int i=0; i<n; ++i) {
if (str[i] == '(') {
top++;
} else {
if (top == 0) {
error++;
break;
}
top--;
}
}
puts (((!error && top == 2) ? "Yes" : "No"));
}
}
return 0;
}

  

2016 Multi-University Training Contest 8的更多相关文章

  1. 2016 Al-Baath University Training Camp Contest-1

    2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...

  2. 2016 Al-Baath University Training Camp Contest-1 E

    Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...

  3. 2016 Al-Baath University Training Camp Contest-1 A

    Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...

  4. 2016 Al-Baath University Training Camp Contest-1 J

    Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...

  5. 2016 Al-Baath University Training Camp Contest-1 I

    Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...

  6. 2016 Al-Baath University Training Camp Contest-1 H

     Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...

  7. 2016 Al-Baath University Training Camp Contest-1 G

    Description The forces of evil are about to disappear since our hero is now on top on the tower of e ...

  8. 2016 Al-Baath University Training Camp Contest-1 F

    Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a ...

  9. 2016 Al-Baath University Training Camp Contest-1 D

    Description X is well known artist, no one knows the secrete behind the beautiful paintings of X exc ...

  10. 2016 Al-Baath University Training Camp Contest-1 C

    Description Rami went back from school and he had an easy homework about bitwise operations (and,or, ...

随机推荐

  1. QT 调用VS2015编写的Dll

    最近在用QT调用VC生成的库,QT使用的是MinGW调试器,出现与动态库不兼容的问题,最后发现QT只能识别VC生成的C格式下的动态库 也就是在导入导出设置时加入extern "C" ...

  2. 知方可补不足~sqlserver中使用sp_who查看sql的进程

    回到目录 在SQLSERVER中每个会话,即每个查询分析器窗口都会产生一个SQL进程,对于那些持续时间短的进程,它们转瞬即失,而对于持续时间比较长的,我们需要希望查看它的运行状态,就可以借助SQL提供 ...

  3. Asp.net中Json的序列化和反序列化(二)

     三.JSON序列化和反序列化日期时间的处理 JSON格式不直接支持日期和时间.DateTime值值显示为“/Date(700000+0500)/”形式的JSON字符串,其中第一个数字(在提供的示例中 ...

  4. Java方法

    所谓方法,就是用来解决一类问题的代码的有序组合,是一个功能模块. 一般情况下,定义一个方法的语法是: 其中: 1. 访问修饰符:方法允许被访问的权限范围, 可以是 public.protected.p ...

  5. css重点

    1.CSS的盒子模型? (1)两种, IE 盒子模型.标准 W3C 盒子模型:IE 的content部分包含了 border 和 pading; (2)盒模型: 内容(content).填充(padd ...

  6. Spring MVC 项目搭建 -5- spring security 使用数据库进行验证

    Spring MVC 项目搭建 -5- spring security 使用数据库进行验证 1.创建数据表格(这里使用的是mysql) CREATE TABLE security_role ( id ...

  7. 2015 多校联赛 ——HDU5386(暴力)

    Sample Input 1 3 5 2 2 1 2 3 3 2 1 3 3 3 3 3 3 3 3 3 3 H 2 3 L 2 2 H 3 3 H 1 3 L 2 3   Sample Output ...

  8. 20155312 张竞予 Exp3 免杀原理与实践

    Exp3 免杀原理与实践 目录 基础问题回答 (1)杀软是如何检测出恶意代码的? (2)免杀是做什么? (3)免杀的基本方法有哪些? 实验总结与体会 实践过程记录 正确使用msf编码器,msfveno ...

  9. Docker部署SonarQube

    依赖 CentOS 7.2+ docker 1.13+ docker-compose 1.20+ 将下面文件内容另存为docker-compose.yml文件,执行docker-compose up ...

  10. UML建模图

    UML 2.0规范 迅速成为建立软件系统可视化.规范.文档的标准.统一建模语言(UML) 也被用于非软件系统的建模,并在很多领域,诸如金融,军事,工程方面应用广泛. UML 2 定义了13种基本的图, ...