2018.7.21NOIP模拟赛?解题报告
题面
预计得分:70 + 60 + 30 = 160
实际得分:40 + 60 + 0 = 100
T1数组开小了
T2比赛结束后5min AC
T3加了个记忆话搜索wa了、、
T1
zbq吊打std啊Orz
此题$O(nlog)$做法:
一个很显然的思路:对每个做括号维护一个大根堆,每次取最大的。
但是这样有不优的情况,比如$()), 1, 3, 5$
那么我们还需要对每个已经加入的右括号维护一个小根堆。每次判断是否替换掉更小的会更优
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define LL long long
using namespace std;
const int MAXN = * 1e5 + , INF = 1e9;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N;
priority_queue<int> mx;
priority_queue<int, vector<int>, greater<int> >mi;
char s[MAXN];
int a[MAXN];
int main() {
freopen("bracket.in", "r", stdin);
freopen("bracket.out", "w", stdout);
N = read();
scanf("%s", s + );
for(int i = ; i <= N; i++) a[i] = read();
int ans = ;
for(int i = ; i <= N; i++) {
if(s[i] == '(') mx.push(a[i]);
if(s[i] == ')')
if(!mx.empty() && a[i] + mx.top() > ) {
if(mi.empty() || (!mi.empty() && mx.top() > - mi.top())) ans += a[i] + mx.top(), mx.pop(), mi.push(a[i]);
else if(!mi.empty() && a[i] > mi.top()) ans -= mi.top(), mi.pop(), ans += a[i], mi.push(a[i]);
} else if(!mi.empty() && a[i] > mi.top()) ans -= mi.top(), mi.pop(), ans += a[i], mi.push(a[i]); }
printf("%d", ans);
return ;
}
T2
很显然每个位置就那么几种可能
直接暴力判断就好,前缀和优化
/*
60:直接BFS
*/
#include<cstdio>
#include<algorithm>
#include<queue>
#define LL long long
using namespace std;
const int MAXN = 1e5 + , INF = 1e9;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, M, K;
int a[][], down[MAXN], vis[][];
struct Node {
int xx1, yy1, xx2, yy2;
}p[MAXN];
bool pd(int x, int y) {
if(x < || x > N || y < || y > M) return ;
return ;
}
int hsum[][], lsum[][];
bool line(int x1, int y11, int x2, int y2, int id) {
if(pd(x1, y11) || pd(x2, y2)) return ;
if(x1 == x2) {
if(y11 > y2) swap(y11, y2);
if(hsum[x1][y2] - hsum[x1][y11 - ] == ) return ;
if(a[x1][y11] == id && hsum[x1][y2] - hsum[x1][y11] == ) return ;
if(a[x1][y2] == id && hsum[x1][y2 - ] - hsum[x1][y11 - ] == ) return ;
return ;
}
if(y11 == y2) {
if(x1 > x2) swap(x1, x2);
if(lsum[x2][y2] - lsum[x1 - ][y2] == ) return ;
if(a[x1][y11] == id && lsum[x2][y2] - lsum[x1][y2] == ) return ;
if(a[x2][y11] == id && lsum[x2 - ][y2] - lsum[x1 - ][y2] ==) return ;
return ;
}
}
int main() {
freopen("linking.in", "r", stdin);
freopen("linking.out", "w", stdout);
N = read(); M = read(); K = read();
for(int i = ; i <= K; i++) {
int xx1 = read(), yy1 = read(), xx2 = read(), yy2 = read();
a[xx1][yy1] = i;
a[xx2][yy2] = i;
p[i] = (Node) {xx1, yy1, xx2, yy2};
}
for(int i = ; i <= N; i++)
for(int j = ; j <= M; j++)
hsum[i][j] = hsum[i][j - ] + a[i][j],
lsum[i][j] = lsum[i - ][j] + a[i][j];
int ans = ;
for(int i = ; i <= K; i++) {
int xx1 = p[i].xx1, yy1 = p[i].yy1, xx2 = p[i].xx2, yy2 = p[i].yy2, flag = ;
if(yy1 > yy2) swap(yy1, yy2), swap(xx1, xx2);
for(int k = ; k <= N; k++)
if(!line(xx2, yy2, k, yy2, i) && !line(xx1, yy1, k, yy1, i) && !line(k, yy1, k, yy2, i))
{ans++; flag = ; break;}
if(flag == ) continue;
for(int k = ; k <= M; k++)
if(!line(xx2, yy2, xx2, k, i) && !line(xx2, k, xx1, k, i) && !line(xx1, yy1, xx1, k, i))
{ans++; break;}
}
printf("%d", ans);
return ;
}
/*
20 20 3
1 1 20 20
2 1 2 20
3 1 1 20 3 3 3
1 3 2 2
1 1 3 3
1 2 2 1 */
T3
神仙题。
很显然答案是一棵树,那么直接书上倍增就好
满分做法不会。。
2018.7.21NOIP模拟赛?解题报告的更多相关文章
- 2018.10.26NOIP模拟赛解题报告
心路历程 预计得分:\(100 + 100 + 70\) 实际得分:\(40 + 100 + 70\) 妈妈我又挂分了qwq..T1过了大样例就没管,直到临考试结束前\(10min\)才发现大样例是假 ...
- 2018.10.17NOIP模拟赛解题报告
心路历程 预计得分:\(100 + 100 +100\) 实际得分:\(100 + 100 + 60\) 辣鸡模拟赛.. 5min切掉T1,看了一下T2 T3,感觉T3会被艹爆因为太原了.. 淦了20 ...
- 2018.10.23NOIP模拟赛解题报告
心路历程 预计得分:\(100 + 50 + (10 \sim 50)\) 实际得分:\(100 + 10 + 50\) 这可能是我打的最懵逼的一场考试没有之一.. T1两个小时才做出来也是醉了. T ...
- 2018.10.16 NOIP模拟赛解题报告
心路历程 预计得分:\(100 + 100 + 20 = 220\) 实际得分:\(100 + 100 + 30 = 230\) 辣鸡模拟赛.. T1T2都是一眼题,T3考验卡常数还只有一档暴力分. ...
- 10.30 NFLS-NOIP模拟赛 解题报告
总结:今天去了NOIP模拟赛,其实是几道USACO的经典的题目,第一题和最后一题都有思路,第二题是我一开始写了个spfa,写了一半中途发现应该是矩阵乘法,然后没做完,然后就没有然后了!第二题的暴力都没 ...
- 20201101gryz模拟赛解题报告
写在前面 2020rp++ 停课的第一场模拟赛 拿上一年的上一年的day1来考的, 结果得分期望220pts,实际135pts,rank3,太菜了 考着考着机房灯突然灭了,当时慌的一批 以为断电代码要 ...
- 2018.10.29 NOIP2018模拟赛 解题报告
得分: \(70+60+0=130\)(\(T3\)来不及打了,结果爆\(0\)) \(T1\):简单的求和(点此看题面) 原题: [HDU4473]Exam 这道题其实就是上面那题的弱化版,只不过把 ...
- 2018.10.03 NOIP+ 模拟赛 解题报告
得分: \(30+5+0=35\)(考得真不咋滴) \(T1\):奥义商店(点此看题面) 以为很简单,对着这题想了一个多小时,最后果断打了个暴力交了... ... 看完题解发现其实也不是很难. 对于\ ...
- 2018.10.05 TOPOI提高组模拟赛 解题报告
得分: \(100+5+100=205\)(真的是出乎意料) \(T1\):抵制克苏恩(点此看题面) 原题: [BZOJ4832][Lydsy1704月赛] 抵制克苏恩 应该还是一个比较简单的\(DP ...
随机推荐
- Typescript 常见写法
一.Typescript 中数组 let list: number[] = [1, 2, 3]; let list: Array<number> = [1, 2, 3];
- EhCache+Redis实现分布式缓存
Ehcache集群模式 由于 EhCache 是进程中的缓存系统,一旦将应用部署在集群环境中,每一个节点维护各自的缓存数据,当某个节点对缓存数据进行更新,这些更新的数据无法在其它节点中共享,这不仅会降 ...
- jconsole工具检测堆内存变化的使用
jconsole将Java写的程序检测. 从Java 5开始 引入了 JConsole.JConsole 是一个内置 Java 性能分析器,可以从命令行或在 GUI shell 中运行.您可以轻松地使 ...
- html5--6-9 CSS选择器6--伪类选择器
html5--6-9 CSS选择器6--伪类选择器 实例 @charset="UTF-8"; /*:root{background: green}*/ /*li:first-chi ...
- 一步一步学Silverlight 2系列(17):数据与通信之ADO.NET Data Services
概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...
- Oracle:impdb导入
最近有现场给我一份用expdp导出dmp文件,我用imp导入时,报错.因为导出dmp的数据库是11g,导入的数据库也是11g, 但客户端安装的是10g,不能用imp导入:所以只能试着用impdp导入: ...
- Python web —— Selenium 库
Selenium:硒,一种化学元素. Selenium 是 Python 下第三方浏览器自动化工具. 1. Firefox/Chrome from selenium import webdriver ...
- Unable to instantiate receiver XXXXXX
运行一个工程的时候时logcat中出现了“Unable to instantiate receiver XX..”. 检查后发现,由于是东拼西凑的代码,所以在Manifest文件里注册了Receive ...
- POJ2689:Prime Distance(大数区间素数筛)
The branch of mathematics called number theory is about properties of numbers. One of the areas that ...
- BZOJ_1812_[Ioi2005]riv_树形DP
BZOJ_1812_[Ioi2005]riv_树形DP Description 几乎整个Byteland王国都被森林和河流所覆盖.小点的河汇聚到一起,形成了稍大点的河.就这样,所有的河水都汇聚并流进了 ...