题面

预计得分: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模拟赛?解题报告的更多相关文章

  1. 2018.10.26NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 100 + 70\) 实际得分:\(40 + 100 + 70\) 妈妈我又挂分了qwq..T1过了大样例就没管,直到临考试结束前\(10min\)才发现大样例是假 ...

  2. 2018.10.17NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 100 +100\) 实际得分:\(100 + 100 + 60\) 辣鸡模拟赛.. 5min切掉T1,看了一下T2 T3,感觉T3会被艹爆因为太原了.. 淦了20 ...

  3. 2018.10.23NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 50 + (10 \sim 50)\) 实际得分:\(100 + 10 + 50\) 这可能是我打的最懵逼的一场考试没有之一.. T1两个小时才做出来也是醉了. T ...

  4. 2018.10.16 NOIP模拟赛解题报告

    心路历程 预计得分:\(100 + 100 + 20 = 220\) 实际得分:\(100 + 100 + 30 = 230\) 辣鸡模拟赛.. T1T2都是一眼题,T3考验卡常数还只有一档暴力分. ...

  5. 10.30 NFLS-NOIP模拟赛 解题报告

    总结:今天去了NOIP模拟赛,其实是几道USACO的经典的题目,第一题和最后一题都有思路,第二题是我一开始写了个spfa,写了一半中途发现应该是矩阵乘法,然后没做完,然后就没有然后了!第二题的暴力都没 ...

  6. 20201101gryz模拟赛解题报告

    写在前面 2020rp++ 停课的第一场模拟赛 拿上一年的上一年的day1来考的, 结果得分期望220pts,实际135pts,rank3,太菜了 考着考着机房灯突然灭了,当时慌的一批 以为断电代码要 ...

  7. 2018.10.29 NOIP2018模拟赛 解题报告

    得分: \(70+60+0=130\)(\(T3\)来不及打了,结果爆\(0\)) \(T1\):简单的求和(点此看题面) 原题: [HDU4473]Exam 这道题其实就是上面那题的弱化版,只不过把 ...

  8. 2018.10.03 NOIP+ 模拟赛 解题报告

    得分: \(30+5+0=35\)(考得真不咋滴) \(T1\):奥义商店(点此看题面) 以为很简单,对着这题想了一个多小时,最后果断打了个暴力交了... ... 看完题解发现其实也不是很难. 对于\ ...

  9. 2018.10.05 TOPOI提高组模拟赛 解题报告

    得分: \(100+5+100=205\)(真的是出乎意料) \(T1\):抵制克苏恩(点此看题面) 原题: [BZOJ4832][Lydsy1704月赛] 抵制克苏恩 应该还是一个比较简单的\(DP ...

随机推荐

  1. D. Babaei and Birthday Cake--- Codeforces Round #343 (Div. 2)

    D. Babaei and Birthday Cake time limit per test 2 seconds memory limit per test 256 megabytes input ...

  2. nginx、mysql、php等各编译参数查询

    查看nginx编译参数:/usr/local/nginx/sbin/nginx -V 查看apache编译参数:cat /usr/local/apache2/build/config.nice 查看m ...

  3. Silverlight结合Web Service进行文件上传

    search了非常多的文章,总算勉强实现了.有许多不完善的地方. 在HCLoad.Web项目下新建目录Pics复制一张图片到根目录下. 图片名:Bubble.jpg 右击->属性->生成操 ...

  4. 子元素margin带动父元素拖动

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. Java多线程:线程状态以及wait(), notify(), notifyAll()

    一. 线程状态类型1. 新建状态(New):新创建了一个线程对象.2. 就绪状态(Runnable):线程对象创建后,其他线程调用了该对象的start()方法.该状态的线程位于可运行线程池中,变得可运 ...

  6. lnmp-详细编译安装步骤

    CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14 一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这 ...

  7. select查询不到实际存在的

    转自:https://blog.csdn.net/jack0201/article/details/77868604

  8. jetty的web部署

    jetty版本:jetty-distribution-9.4.8.v20171121,jdk1.8 1.下载jetty 2.cd demo-base 3.java -jar ../start.jar ...

  9. bzoj 3594: [Scoi2014]方伯伯的玉米田【二维树状数组+dp】

    设f[i][j]为前i棵玉米被拔高了j(因为是单调不降所以前面越高越好,所以每次拔一个前缀),转移是f[i][j]=f[k][l]+1,l<=j,a[k]+l<=a[i]+j,然后用二维树 ...

  10. bzoj 2131: 免费的馅饼【dp+树状数组】

    简单粗暴的dp应该是把馅饼按时间排序然后设f[i]为i接到馅饼能获得的最大代价,转移是f[i]=max(f[j])+v[i],t[j]<=t[i],2t[i]-2t[j]>=abs(p[i ...