文章转载自:https://mp.weixin.qq.com/s/W9b28CFBEmxBPz5bGd1-hw

教程pdf文件下载地址

https://files.cnblogs.com/files/sanduzxcvbnm/ELK基于ElastAlert实现日志的微信报警.pdf

官方文档下载地址

https://files.cnblogs.com/files/sanduzxcvbnm/elastalert-readthedocs-io-en-latest.pdf

注意事项:

1.文章中凡是用python的均表示的是使用python3的版本,但是不能使用python3,因为安装的elastalert模块中好多文件开头用的是#!/usr/bin/env python,或者没有添加这个

也就是说假若系统使用双版本的python,python表示的是2版本,python3表示的是3版本,需要把python表示的2的版本链接给删除,换成python3的,最终结果是执行python出现的是3的版本信息。

2.关于elastalert_modules文件夹,并不是放在elastalert在python3的安装路径下,放在~/elastalert路径下了,然后进入到~/elastalert路径下,执行命令:python -m elastalert.elastalert --verbose --config /app/elastalert/config.yaml --rule /app/elastalert/example_rules/sms-applog.yaml

一、ElastAlert介绍

在日志管理上我们使用Elasticsearch,Logstash和Kibana技术栈来管理不断增长的数据和日志,但是对于错误日志的监控ELK架构并没有提供,所以我们需要使用到第三方工具ElastAlert,来帮助我们及时发现业务中存在的问题。

ElastAlert通过定期查询Elasticsearch,并将数据传递到规则类型,该规则类型确定何时找到匹配项。发生匹配时,将为该警报提供一个或多个警报,这些警报将根据匹配采取行动。

这是由一组规则配置的,每个规则定义一个查询,一个规则类型和一组警报。

ElastAlert支持以下方式报警

  • Command (可调用短信接口)
  • Email
  • JIRA
  • OpsGenie
  • SNS
  • HipChat
  • Slack
  • Telegram
  • Debug
  • Stomp

除了这种基本用法外,还有许多其他功能使警报更加有用:

  • 警报链接到Kibana仪表板
  • 任意字段的合计计数
  • 将警报合并为定期报告
  • 通过使用唯一键字段来分隔警报
  • 拦截并增强比赛数据

二、部署ElastAlert

. 1. 部署所需环境

ELK 环境部署

EFK6.3+kafka+logstash日志分析平台集群

安装依赖包

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

部署python3.6

mkdir -p /usr/local/python3
cd /usr/local/python3
wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
tar xf Python-3.6.9.tgz
cd Python-3.6.9
./configure --prefix=/usr/local/python3
make && make install

配置环境变量

# 将python2.7 软链删除,换成python3.6
rm /usr/bin/python
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
rm /usr/bin/pip
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip # 最终效果
[root@docker Python-3.6.9]# ll /usr/bin/python*
lrwxrwxrwx 1 root root 32 Sep 4 09:57 /usr/bin/python -> /usr/local/python3/bin/python3.6
lrwxrwxrwx. 1 root root 9 Oct 10 2019 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 7216 Aug 7 2019 /usr/bin/python2.7
[root@docker Python-3.6.9]# ll /usr/bin/pip*
lrwxrwxrwx 1 root root 27 Sep 4 09:57 /usr/bin/pip -> /usr/local/python3/bin/pip3
-rwxr-xr-x 1 root root 284 Jan 29 2020 /usr/bin/pip2
-rwxr-xr-x 1 root root 288 Jan 29 2020 /usr/bin/pip2.7

验证版本

# python
Python 3.6.9 (default, Jun 2 2020, 12:12:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
# pip -V
pip 18.1 from /usr/local/python3/lib/python3.6/site-packages/pip (python 3.6)

. 2. 部署ElastAlert

cd /app
git clone https://github.com/Yelp/elastalert.git

安装模块:

cd elastalert
pip install "setuptools>=11.3"
python setup.py install
pip install -r requirements.txt

安装完后,会在 /usr/local/bin/ 或者 /usr/local/python3/bin/ 下生成4个elastalert命令


$ ll /usr/local/bin/elastalert*
-rwxr-xr-x 1 root root 396 2月 14 10:03 /usr/local/bin/elastalert
-rwxr-xr-x 1 root root 422 2月 14 10:03 /usr/local/bin/elastalert-create-index
-rwxr-xr-x 1 root root 430 2月 14 10:03 /usr/local/bin/elastalert-rule-from-kibana
-rwxr-xr-x 1 root root 416 2月 14 10:03 /usr/local/bin/elastalert-test-rule

根据Elasticsearch的版本,您可能需要手动安装正确版本的elasticsearch-py。

Elasticsearch 5.0+:

pip install "elasticsearch>=5.0.0"

Elasticsearch 2.X:

pip install "elasticsearch<3.0.0"

. 3. 配置ElastAlert

配置config.yaml 文件

# cp config.yaml.example  config.yaml
# cat config.yaml
rules_folder: example_rules
run_every:
seconds: 10
buffer_time:
minutes: 15
es_host: 10.1.144.208
es_port: 9201
#es_username: elastic
#es_password: 123456
writeback_index: elastalert_status
alert_time_limit:
days: 2

rules_folder:ElastAlert从中加载规则配置文件的位置。它将尝试加载文件夹中的每个.yaml文件。没有任何有效规则,ElastAlert将无法启动。

run_every:ElastAlert多久查询一次Elasticsearch的时间。

buffer_time:查询窗口的大小,从运行每个查询的时间开始向后延伸。对于其中use_count_query或use_terms_query设置为true的规则,将忽略此值。

es_host:是Elasticsearch群集的地址,ElastAlert将在其中存储有关其状态,查询运行,警报和错误的数据。

es_port:es对应的端口。

es_username:可选的; 用于连接的basic-auth用户名es_host。

es_password:可选的; 用于连接的basic-auth密码es_host。

es_send_get_body_as:可选的; 方法查询Elasticsearch - GET,POST或source。默认是GET

writeback_index:ElastAlert将在其中存储数据的索引的名称。我们稍后将创建此索引。

alert_time_limit:失败警报的重试窗口。

创建elastalert-create-index索引

# elastalert-create-index
New index name (Default elastalert_status)
Name of existing index to copy (Default None)
New index elastalert_status created
Done!

具体效果

三、使用微信报警

由于ElastAlert没有内置企业微信的报警方式,我们还需要使用一个开源插件elastalert-wechat-plugin来实现微信的报警,Github项目地址

. 1. 下载项目文件

mkdir -p ~/elastalert/elastalert_modules
# 下载该文件的地址有问题,导致无法下载,因此这一步就不下载了,直接使用下一步修改好的内容复制粘贴创建这个文件即可
# wget -P ~/elastalert/elastalert_modules/ wget https://raw.githubusercontent.com/anjia0532/elastalert-wechat-plugin/master/elastalert_modules/wechat_qiye_alert.py
touch ~/elastalert/elastalert_modules/__init__.py

. 2. 修改插件源码

由于这个插件是基于python2.x版本开发的,而ElastAlert的最新版本使用的是python3.6版本开发,所以需要改一些代码,以便正常运行,另外还添添加了转中文字符功能。

wechat_qiye_alert.py修改后如下:

#! /usr/bin/env python
# -*- coding: utf-8 -*- import json
import datetime
from elastalert.alerts import Alerter, BasicMatchString
from requests.exceptions import RequestException
from elastalert.util import elastalert_logger,EAException #[感谢minminmsn分享](https://github.com/anjia0532/elastalert-wechat-plugin/issues/2#issuecomment-311014492)
import requests
from elastalert_modules.MyEncoder import MyEncoder '''
#################################################################
# 微信企业号推送消息 #
# #
# 作者: AnJia <anjia0532@gmail.com> #
# 作者博客: https://anjia.ml/ #
# Github: https://github.com/anjia0532/elastalert-wechat-plugin #
# #
#################################################################
'''
class WeChatAlerter(Alerter): #企业号id,secret,应用id必填 required_options = frozenset(['corp_id','secret','agent_id']) def __init__(self, *args):
super(WeChatAlerter, self).__init__(*args)
self.corp_id = self.rule.get('corp_id', '') #企业号id
self.secret = self.rule.get('secret', '') #secret
self.agent_id = self.rule.get('agent_id', '') #应用id self.party_id = self.rule.get('party_id') #部门id
self.user_id = self.rule.get('user_id', '') #用户id,多人用 | 分割,全部用 @all
self.tag_id = self.rule.get('tag_id', '') #标签id
self.access_token = '' #微信身份令牌
self.expires_in=datetime.datetime.now() - datetime.timedelta(seconds=60) def create_default_title(self, matches):
subject = 'ElastAlert: %s' % (self.rule['name'])
return subject def alert(self, matches): if not self.party_id and not self.user_id and not self.tag_id:
elastalert_logger.warn("All touser & toparty & totag invalid") # 参考elastalert的写法
# https://github.com/Yelp/elastalert/blob/master/elastalert/alerts.py#L236-L243
body = self.create_alert_body(matches) #matches 是json格式
#self.create_alert_body(matches)是String格式,详见 [create_alert_body 函数](https://github.com/Yelp/elastalert/blob/master/elastalert/alerts.py) # 微信企业号获取Token文档
# http://qydev.weixin.qq.com/wiki/index.php?title=AccessToken
self.get_token() self.senddata(body) elastalert_logger.info("send message to %s" % (self.corp_id)) def get_token(self): #获取token是有次数限制的,本想本地缓存过期时间和token,但是elastalert每次调用都是一次性的,不能全局缓存
if self.expires_in >= datetime.datetime.now() and self.access_token:
return self.access_token #构建获取token的url
get_token_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s' %(self.corp_id,self.secret) try:
response = requests.get(get_token_url)
response.raise_for_status()
except RequestException as e:
raise EAException("get access_token failed , stacktrace:%s" % e)
#sys.exit("get access_token failed, system exit") token_json = response.json() if 'access_token' not in token_json :
raise EAException("get access_token failed , , the response is :%s" % response.text())
#sys.exit("get access_token failed, system exit") #获取access_token和expires_in
self.access_token = token_json['access_token']
self.expires_in = datetime.datetime.now() + datetime.timedelta(seconds=token_json['expires_in']) return self.access_token def senddata(self, content): #如果需要原始json,需要传入matches # http://qydev.weixin.qq.com/wiki/index.php?title=%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B%E5%8F%8A%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F
# 微信企业号有字符长度限制(2048),超长自动截断 # 参考 http://blog.csdn.net/handsomekang/article/details/9397025
#len utf8 3字节,gbk2 字节,ascii 1字节
if len(content) > 512 :
content = content[:512] + "..." # 微信发送消息文档
# http://qydev.weixin.qq.com/wiki/index.php?title=%E6%B6%88%E6%81%AF%E7%B1%BB%E5%9E%8B%E5%8F%8A%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F
send_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=%s' %( self.access_token) headers = {'content-type': 'application/json'} # 替换消息标题为中文,下面的字段为logstash切分的日志字段
title_dict = {
# "At least": "报警规则:At least",
"@timestamp": "报警时间",
"_index": "索引名称",
"_type": "索引类型",
"ServerIP": "报警主机",
"hostname": "报警机器",
"message": "报警内容",
"class": "报错类",
"lineNum": "报错行",
"num_hits": "文档命中数",
"num_matches": "文档匹配数"
} #print(f"type:{type(content)}")
for k, v in title_dict.items():
content = content.replace(k, v, 1 ) # 最新微信企业号调整校验规则,tagid必须是string类型,如果是数字类型会报错,故而使用str()函数进行转换
payload = {
"touser": self.user_id and str(self.user_id) or '', #用户账户,建议使用tag
"toparty": self.party_id and str(self.party_id) or '', #部门id,建议使用tag
"totag": self.tag_id and str(self.tag_id) or '', #tag可以很灵活的控制发送群体细粒度。比较理想的推送应该是,在heartbeat或者其他elastic工具自定义字段,添加标签id。这边根据自定义的标签id,进行推送
'msgtype': "text",
"agentid": self.agent_id,
"text":{
"content": content.encode('UTF-8').decode("latin1") #避免中文字符发送失败
},
"safe":"0"
} # set https proxy, if it was provided
# 如果需要设置代理,可修改此参数并传入requests
# proxies = {'https': self.pagerduty_proxy} if self.pagerduty_proxy else None
try:
#response = requests.post(send_url, data=json.dumps(payload, ensure_ascii=False), headers=headers)
response = requests.post(send_url, data=json.dumps(payload, cls=MyEncoder, indent=4, ensure_ascii=False), headers=headers)
response.raise_for_status()
except RequestException as e:
raise EAException("send message has error: %s" % e) elastalert_logger.info("send msg and response: %s" % response.text) def get_info(self):
return {'type': 'WeChatAlerter'}

在同级目录下创建MyEncoder.py文件

#!/usr/bin/env python3
# -*- coding: utf-8 -*- import json class MyEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, bytes):
return str(obj, encoding='utf-8')
return json.JSONEncoder.default(self, obj)

. 3. 申请企业微信账号

step 1: 访问网站 注册企业微信账号(不需要企业认证)。

step 2: 访问apps 创建第三方应用,点击创建应用按钮 -> 填写应用信息:

Step3: 创建部门,获取部门ID

步骤详见网址:https://www.cnblogs.com/sanduzxcvbnm/p/13612580.html

. 4. 配置报警规则

配置规则文件

$ cd /app/elastalert/example_rules/
$ cp example_frequency.yaml sms-applog.yaml
$ cat sms-applog.yaml | grep -v ^#
name: 【日志报警】
use_strftine_index: true
type: frequency index: filebeat-*
num_events: 1
timeframe:
minutes: 1
filter:
- query:
query_string:
query: '"\[ERROR\]" NOT "发送邮件失败"' alert:
- "elastalert_modules.wechat_qiye_alert.WeChatAlerter"
corp_id: wxdxxx40b4720f24
secret: xa4pWq63sxxtaZzzEg8X860ZBIoOkToCbh_oNc
agent_id: 1000002
party_id: 2

index:要查询的索引的名称, ES中存在的索引。

num_events:此参数特定于frequency类型,并且是触发警报时的阈值。

filter:用于过滤结果的Elasticsearch过滤器列表,这里的规则定义是除了包含“发送邮件失败”的错误日志,其他所有ERROR的日志都会触发报警。

alert:定义报警方式,我们这里采用企业微信报警。

corp_id:企业微信的接口认证信息

. 5. 运行ElastAlert

# cd ~/elastalert
$ python -m elastalert.elastalert --verbose --config /app/elastalert/config.yaml --rule /app/elastalert/example_rules/sms-applog.yaml
1 rules loaded
INFO:elastalert:Starting up
INFO:elastalert:Disabled rules are: []
INFO:elastalert:Sleeping for 9.999904 seconds
INFO:elastalert:Queried rule 【日志报警】 from 2020-06-05 17:47 CST to 2020-06-05 17:47 CST: 0 / 0 hits
INFO:elastalert:Ran 【日志报警】 from 2020-06-05 17:47 CST to 2020-06-05 17:47 CST: 0 query hits (0 already seen), 0 matches, 0 alerts sent
后台运行
$ nohup python -m elastalert.elastalert --verbose --config /app/elastalert/config.yaml --rule /app/elastalert/example_rules/sms-applog.yaml > nohup.txt 2>&1 &

注意:执行后提示找不到elastalert_modules模块的话,需要在~/目录下创建elastalert文件夹,然后再把elastalert_modules文件夹给放进去,而不是把elastalert_modules文件夹放在elastalert模块的安装路径下

出现这个提示:

是因为设置的接收报警的是一个报警组,但是应用中设置接收报警的是一个微信账户,只需要在应用中找到可接受范围修改成报警组就行了

正常发送报警的消息:

个人企业微信中收到的消息截图:







PDF文件下载地址

延伸:

1.监控规则中监控的日志索引是:filebeat-* ,也就是说在elk中要有这个日志索引存在

2.监控规则如下:

filter:
- query:
query_string:
query: '"\[ERROR\]" NOT "发送邮件失败"'

日志索引中只要不包含"发送邮件失败",凡是包含"[ERROR]"的信息都会触发报警

因此可以这样进行验证:

使用filebeat监控具体某一个日志文件,直接传输给es,但是传输给ES后创建的索引必须是以"filebeat-"开头的,具体可以看这个:https://www.cnblogs.com/sanduzxcvbnm/p/12350618.html

然后呢,手动往这个日志文件中写数据,在kibana中查看这个索引内容,然后查看是否触发报警:

1.手动往监控的日志文件中写数据,含有“[ERROR]”信息就行



2.在kibana中查看上一条数据是否写进来了



3.查看是否报警



4.查看具体报警内容

3.若是想监控多个日志索引怎么办

可以再创建一个yaml报警规则的文件,然后再启动一个命令,指定使用这个报警规则文件

4.目录搞不明白的话可以看如下的目录结构

当前使用的目录结构如下:

目录结构:

/app/elastalert # 以下这些目录和文件是克隆git地址所提供的
└── build
└── changelog.md
└── config.yaml # 配置文件
└── config.yaml.example
└── dist
└── docker-compose.yml
└── Dockerfile-test
└── docs
└── elastalert
└── elastalert.egg-info
└── example_rules # 报警规则目录
└── LICENSE
└── Makefile
└── pytest.ini
└── README.md
└── requirements-dev.txt
└── requirements.txt
└── setup.cfg
└── setup.py
└── supervisord.conf.example
└── tests
└── tox.ini
~/elastalert # 这个是单独创建的目录
├── elastalert_modules
├ ├── __init__.py
├ ├── wechat_qiye_alert.py

使用的命令需要先进入到~/elastalert目录下执行,指定使用的配置文件,指定使用的报警规则

python -m elastalert.elastalert --verbose --config /app/elastalert/config.yaml --rule /app/elastalert/example_rules/sms-applog.yaml
# 后台运行
nohup python -m elastalert.elastalert --verbose --config /app/elastalert/config.yaml --rule /app/elastalert/example_rules/sms-applog.yaml > nohup.txt 2>&1 &

或者采用如下的这种目录结构:

~/elastalert
├── elastalert_modules # 这个是单独创建的目录,里面的这俩文件需要单独创建
├ ├── __init__.py
├ ├── wechat_qiye_alert.py
└── build # 以下这些目录是克隆git地址所提供的
└── changelog.md
└── config.yaml # 配置文件
└── config.yaml.example
└── dist
└── docker-compose.yml
└── Dockerfile-test
└── docs
└── elastalert
└── elastalert.egg-info
└── example_rules # 报警规则目录
└── LICENSE
└── Makefile
└── pytest.ini
└── README.md
└── requirements-dev.txt
└── requirements.txt
└── setup.cfg
└── setup.py
└── supervisord.conf.example
└── tests
└── tox.ini

使用的命令需要先进入到~/elastalert目录下执行,指定使用的报警规则

python -m elastalert.elastalert --verbose --rule example_rules/example_frequency.yaml
```

ELK基于ElastAlert实现日志的微信报警的更多相关文章

  1. ELK基于ElastAlert实现日志的微信报警 ---docker环境

    参考网址:https://github.com/anjia0532/elastalert-docker 1.拉取镜像: docker pull anjia0532/elastalert-docker: ...

  2. elk监听Java日志发送微信报警

    一年前写过logstash根据日志关键词报警 ,今年重温一下.并且记录一下遇到的问题解决办法. Java错误日志一般出现一大坨,如下图: 所以我们的filebeat日志收集器就要改成多行匹配模式,以日 ...

  3. 【ELK】elastalert 日志告警

    一.环境 系统:centos7 elk 版本:7.6.2 1.1 ElastAlert 工作原理 周期性的查询Elastsearch并且将数据传递给规则类型,规则类型定义了需要查询哪些数据. 当一个规 ...

  4. elasticsearch5之Elastalert 安装使用 配置邮件报警和微信报警

    简介 Elastalert是用python2写的一个报警框架(目前支持python2.6和2.7,不支持3.x),github地址为 https://github.com/Yelp/elastaler ...

  5. 基于ELK进行邮箱访问日志的分析

    公司希望能够搭建自己的日志分析系统.现在基于ELK的技术分析日志的公司越来越多,在此也记录一下我利用ELK搭建的日志分析系统. 系统搭建 系统主要是基于elasticsearch+logstash+f ...

  6. ElastAlert监控日志告警Web攻击行为

    由于公司需要监控web攻击行为,而因某些原因搭不了waf,才不得不用ElastAlert进行告警,此为前提. 一.ELK安装 Elasticsearch 是一个分布式.可扩展.实时的搜索与数据分析引擎 ...

  7. 通过脚本发送zabbix微信报警

    实现zabbix通过微信报警的方式也是通过脚本来实现,与邮件报警不同的是,脚本调用的微信的相关接口的获取相对复杂一点 1.申请一个微信公众号(企业号) 申请方法不多说,如果已申请请忽略 2.在微信企业 ...

  8. ELK+FileBeat+Log4Net搭建日志系统

    ELK+FileBeat+Log4Net搭建日志系统 来源:https://www.zybuluo.com/muyanfeixiang/note/608470 标签(空格分隔): ELK Log4Ne ...

  9. 基于Log4Net本地日志服务简单实现

    背景 项目开发中,我们或多或少会使用诸如NLog,Log4Net,Kafka+ELK等等日志套件: 基于关注点分离原则,业务开发的时候不应该关注日志具体实现:并且后续能方便切换其他日志套件: 这里先实 ...

随机推荐

  1. Pytorch Dataloader加速

    在进行多卡训练的时候,经常会出现GPU利用率上不来的情况,无法发挥硬件的最大实力. 造成这种现象最有可能的原因是,CPU生成数据的能力,已经跟不上GPU处理数据的能力. 方法一 常见的方法为修改Dat ...

  2. surging作者出具压测结果

    前言 首先回应下@wen-wen 所贴的压测报告,我也把我和客户压测碰到的问题,和压测结果贴出来,这个结果是由客户提供的.不会有任何的舞弊手脚问题 问题一:Task.Run慎用 首先在最新的社区版本已 ...

  3. Solution -「基环树」做题记录

    写的大多只是思路,比较简单的细节和证明过程就不放了,有需者自取. 基环树简介 简单说一说基环树吧.由名字扩展可得这是一类以环为基础的树(当然显然它不是树. 通常的表现形式是一棵树再加一条非树边,把图画 ...

  4. WebWorker:工作者线程初探

    WebWorker:工作者线程初探 参考资料: 1.Web Worker 使用教程 - 阮一峰:http://www.ruanyifeng.com/blog/2018/07/web-worker.ht ...

  5. 【定时功能】消息的定时发送-基于RocketMQ

    一.功能介绍 要实现一个消息的定时发送功能,也就是让消息可以在某一天某一个时间具体节点进行发送.而我们公司的业务场景是类似短信的业务,而且数量不小,用户会进行号码.消息内容.定时发送时间等信息的提交. ...

  6. windows下memcache安装

    Windows下的Memcache安装:1. 下载memcache的windows稳定版,解压放某个盘下面,比如在c:memcached2. 在终端(也即cmd命令界面)下输入 'c:memcache ...

  7. 【Github开源项目体验】- ZFile 基于 Java 的在线网盘

    [Github开源项目体验]- ZFile 基于 Java 的在线网盘 在线云盘.网盘.OneDrive.云存储.私有云.对象存储.h5ai.上传.下载 date: 2022-08-02 addres ...

  8. 小白之Python基础(四)

    条件判断和循环: 1.条件判断类型: 1)if语句:(注意:if中的条件如果是:非零数值.非空字符串.非空list等,就判断为True,否则为False.) 2)if-else语句: 3)if-eli ...

  9. 过年好,新一代大数据任务调度系统 - Apache DolphinScheduler 1.3.5 发布

    节后上班第一天,新一代大数据任务调度 - Apache DolphinScheduler(incubator) 就迎来了好消息 - 在社区 20 多位小伙伴的贡献与努力下,社区发布了 1.3.5 版本 ...

  10. NC20242 [SCOI2005]最大子矩阵

    题目链接 题目 题目描述 这里有一个n*m的矩阵,请你选出其中k个子矩阵,使得这个k个子矩阵分值之和最大. 注意:选出的k个子矩阵 不能相互重叠. 输入描述 第一行为n,m,k(1 ≤ n ≤ 100 ...