「日常训练」 Mike and Fun (CFR305D2B)
2024-10-21 09:48:16
题意(CodeForces 548B)
每次对01矩阵中的一位取反,问每次操作后,单列中最长连续1的长度。
分析
非常非常简单,但是我当时训练的时候WA了四次。。。无力吐槽了,人间 不值得.jpg
代码
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ZERO(x) memset((x), 0, sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define QUICKIO \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
const int MAXN=500;
bool status[MAXN+5][MAXN+5];
int main()
{
QUICKIO
int n,m,k; cin>>n>>m>>k;
rep(i,1,n)
rep(j,1,m)
cin>>status[i][j];
int row[MAXN+5]; ZERO(row);
rep(i,1,n)
{
int tmp=0;
rep(j,1,m)
{
if(status[i][j])
{
if(j>1 && status[i][j-1])
tmp++;
else tmp=1;
}
else
{
row[i]=max(tmp,row[i]);
tmp=0;
}
}
row[i]=max(tmp,row[i]);
}
rep(i,1,k)
{
int tmp=0;
int x,y; cin>>x>>y;
status[x][y]=!status[x][y];
row[x]=0;
rep(j,1,m)
{
if(status[x][j])
{
if(j>1 && status[x][j-1])
tmp++;
else tmp=1;
}
else
{
row[x]=max(tmp,row[x]);
tmp=0;
}
}
row[x]=max(tmp,row[x]);
int maxr=0;
rep(i,1,n)
maxr=max(maxr,row[i]);
cout<<maxr<<endl;
}
return 0;
}
最新文章
- 兼容版本实现 XMLHttpRequest
- IOS开发初步
- PHP开发知识
- Waiting Processed Cancelable ShowDialog (Release 2)
- iOS - Swift 基本语法
- Codeforces 712 D. Memory and Scores (DP+滚动数组+前缀和优化)
- java读取照片信息 获取照片拍摄时的经纬度
- Decision Boundaries for Deep Learning and other Machine Learning classifiers
- solaris 操作系统配置联网
- _WSAStartup@8,该符号在函数 _main 中被引用
- Properties类对于文件的读取和写入
- vscode插件解析-BookMark
- 从零开始学安全(十)●TCP/IP协议栈
- 【【洛谷P2678 跳石头】——%%%ShawnZhou大佬】
- Light Oj 1003
- Android studio 启动模拟器出现 VT-x is disabled in BIOS 以及 /dev/kvm is not found
- Scala进阶之路-并发编程模型Akka入门篇
- (转)Awesome Object Detection
- xcode代码没颜色的解决方案
- JavaScript setInterval 与 setTimeout 区别