题面

预计得分: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. (C\C++)inline关键字

    背景(C&C++中) inline关键字用来定义一个类的内联函数,引入它的主要原因是用它替代C中表达式形式的宏定义. 表达式形式的宏定义如: #define ExpressionName(Va ...

  2. CodeForces - 55D Beautiful numbers —— 数位DP

    题目链接:https://vjudge.net/problem/CodeForces-55D D. Beautiful numbers time limit per test 4 seconds me ...

  3. JQuery操作TABLE,及console.info问题。

    还用alert 吗?看看console.info吧,代码的测试平台:ie9, firefox12 ​1. [代码][JavaScript]代码<!DOCTYPE html><html ...

  4. hdu acm 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2191 题目意思:有 资金 n 和 m 种类型的大米,对第 i 种类型的大米,价格.数量.袋数分别是: ...

  5. hdu2544 迪杰斯特拉题目优化

    点击打开题目链接 迪杰斯特拉的用法不多讲,详见  点击打开链接 . 下面两个代码: 这个是用邻接矩阵存图的迪杰斯特拉. #include<stdio.h> int main() { int ...

  6. 【opencv】opencv在图片、视频嵌中英文字符的方法

    转自:http://www.cnblogs.com/hujingshuang/p/5119015.html 说明:本博文是根据前人已有的成果并结合自己的理解而成的.为了避免让读者感到繁琐,我将运用小学 ...

  7. NSArray是强引用容器

    经常比较疑惑NSArray.NSDictionary.NSSet这几个对象容器管理对象所采用的方式是“强引用”还是“弱引用”. 通过简单的命令行程序得到的结论是“NSArray.NSDictionar ...

  8. 【207】WinForm Chart类

    目录: 在工具箱中找到 Chart 控件并使用 设置 Chart 属性 代码中设置属性 属性中设置属性 Chart 类说明 ChartAreas ChartAreaCollection 类 Chart ...

  9. View Programming Guide for iOS ---- iOS 视图编程指南(三)---Windows

    Windows Every iOS application needs at least one window—an instance of the UIWindow class—and some m ...

  10. k8s-RBAC授权-十六

    一.简介 基于角色的访问控制(“RBAC”) http://docs.kubernetes.org.cn/80.html (1) Kubernetes的授权是基于插件形式的,常用的授权插件有以下几种: ...