Codeforces Round #305 (Div. 2)_B
来源:互联网 发布:沙箱 行为分析软件 编辑:程序博客网 时间:2024/05/29 18:54
题意:输入一个n*m的表格 询问q次 表格内只含有0和1 每次询问输入单元的行列 若为1则变成0 若为0则变成1 输出每次询问后该表格中行的最长连续1
比较麻烦 水一发~
#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;int n,m,q;int grid[510][510];int maxlen[510];int find_max(int row){ int Max=0,s=1,Max1=0; for(int i=s;i<=m;i++) { if(grid[row][i]==1) { for(int j=i;j<=m;j++) { if(grid[row][j]==1) Max1++; if(j==m) { Max=max(Max,Max1); Max1=0; } if(!grid[row][j]) { Max=max(Max,Max1); Max1=0; } } } } return Max;}int main(){ while(~scanf("%d%d%d",&n,&m,&q)) { memset(grid,-1,sizeof(grid)); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&grid[i][j]); for(int i=1;i<=n;i++) { grid[i][m+1]=find_max(i); } int qi,qj; while(q--) { scanf("%d%d",&qi,&qj); if(grid[qi][qj]) grid[qi][qj]=0; else grid[qi][qj]=1; grid[qi][m+1]=find_max(qi); int MAX=-1; for(int i=1;i<=n;i++) { if(MAX<grid[i][m+1]) MAX=grid[i][m+1]; } printf("%d\n",MAX); } } return 0;}
0 0
- Codeforces Round #305 (Div. 2)_B
- Codeforces Round #306 (Div. 2)_B
- Codeforces Round #332 (Div. 2)_B. Spongebob and Joke
- Round #232 (Div. 2)_B
- Codeforces Round #328 (Div. 2)_B. The Monster and the Squirrel
- Codeforces Beta Round #2_B. The least round way(DP)
- Codeforces Round #305 (Div. 2)
- Codeforces Round #305 (Div. 2)
- Codeforces Round #305 (Div. 2)
- Codeforces Round #305 (Div. 2)_A
- Codeforces Round #305 (Div.2) D
- Codeforces Round #305 (Div. 2) B D
- Codeforces Round #305 (Div. 2) E
- Codeforces Round #305 (Div. 2).D
- Codeforces Round #305 (Div. 2) D 栈
- Educational Codeforces Round 2_B. Queries about less or equal elements
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- linux下安装jdk1.6版本显示1.4,修改默认jdk版本
- LeetCode(5) Longest Palindromic Substring
- 今天开始尝试每天写博客
- 并发 并行 同步 异步 多线程 阻塞 非阻塞的区别
- 迅为适合初学者的Cortex-A9+Android视频教程的4412开发板
- Codeforces Round #305 (Div. 2)_B
- quartusII综合报错(Error (10028): Can't resolve multiple constant drivers for net "txd_cnt[3]")
- Intellij IDEA 配置Subversion插件
- X86架构了解(二)——中断与异常
- 黑马程序员(一)——初识java
- 解决Gitlab的Gravatar头像无法显示的问题
- gem5中maxinsts和warmup-insts参数含义解析
- plsql中显示的中文乱码
- 小哈的日记