题意(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;
}

最新文章

  1. 兼容版本实现 XMLHttpRequest
  2. IOS开发初步
  3. PHP开发知识
  4. Waiting Processed Cancelable ShowDialog (Release 2)
  5. iOS - Swift 基本语法
  6. Codeforces 712 D. Memory and Scores (DP+滚动数组+前缀和优化)
  7. java读取照片信息 获取照片拍摄时的经纬度
  8. Decision Boundaries for Deep Learning and other Machine Learning classifiers
  9. solaris 操作系统配置联网
  10. _WSAStartup@8,该符号在函数 _main 中被引用
  11. Properties类对于文件的读取和写入
  12. vscode插件解析-BookMark
  13. 从零开始学安全(十)●TCP/IP协议栈
  14. 【【洛谷P2678 跳石头】——%%%ShawnZhou大佬】
  15. Light Oj 1003
  16. Android studio 启动模拟器出现 VT-x is disabled in BIOS 以及 /dev/kvm is not found
  17. Scala进阶之路-并发编程模型Akka入门篇
  18. (转)Awesome Object Detection
  19. xcode代码没颜色的解决方案
  20. JavaScript setInterval 与 setTimeout 区别

热门文章

  1. js数组、字符串常用方法
  2. python 并发编程之协程
  3. Entity Framework 三
  4. Angularjs 数据双向绑定
  5. VMware虚拟机修改BIOS启动项
  6. Element.getBoundingClientRect()
  7. [Linux/Unix]常用命令
  8. Django url处理
  9. 配置Github秘钥
  10. 实现php Curl 调用不同项目中方法