poj 3467
来源:互联网 发布:vb.net 多线程带参数 编辑:程序博客网 时间:2024/06/04 19:17
挺让人泪奔的一道题。
#include <vector>#include <string>#include <iostream>#include <algorithm>#include <queue>#include <set>#include <map>#include <sstream>#include <iomanip>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;typedef long long ll;int mat[110][110],n,m,c;int col[110],ok[110][110];int fuck(int x,int y,int c){ int tx,ty; tx=x+c,ty=y; if(tx<0 || ty<0) return 0; if(!mat[tx][ty] || mat[tx][ty]!=mat[x][y]) return 0; tx=x-c,ty=y; if(tx<0 || ty<0) return 0; if(!mat[tx][ty] || mat[tx][ty]!=mat[x][y]) return 0; tx=x,ty=y+c; if(!mat[tx][ty] || mat[tx][ty]!=mat[x][y]) return 0; tx=x,ty=y-c; if(tx<0 || ty<0) return 0; if(!mat[tx][ty] || mat[tx][ty]!=mat[x][y]) return 0; return 1;}int add(int x,int y){ int ans=0; for(int i=1;i<=210;i++){ if(fuck(x,y,i)) ans++; else break; } return ans;}//c is originvoid _do1(int x,int y,int c){ if(mat[x][y]==c) return ; col[mat[x][y]]-=ok[x][y]; mat[x][y]=c; ok[x][y]=add(x,y); col[mat[x][y]]+=ok[x][y]; for(int i=1;i<=n;i++){ if(i==x) continue; col[mat[i][y]]-=ok[i][y]; ok[i][y]=add(i,y); col[mat[i][y]]+=ok[i][y]; } for(int i=1;i<=m;i++){ if(i==y) continue; col[mat[x][i]]-=ok[x][i]; ok[x][i]=add(x,i); col[mat[x][i]]+=ok[x][i]; }}void _do2(){ for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){ ok[i][j]=add(i,j); col[mat[i][j]]+=ok[i][j]; }}void init(){ _do2();}int main(){ int q; char op[10]; while(~scanf("%d%d%d%d",&n,&m,&c,&q)){ memset(mat,0,sizeof(mat)); memset(col,0,sizeof(col)); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&mat[i][j]); init(); while(q--){ int _x,_y,_c; scanf("%s",op); if(op[0]=='C'){ scanf("%d%d%d",&_x,&_y,&_c); _do1(_x,_y,_c); } else { scanf("%d",&_c); printf("%d\n",col[_c]); } } } return 0;}/*3 3 3 61 1 11 1 11 1 1C 1 2 2Q 1C 1 2 1Q 1C 1 1 2Q 14 4 3 61 1 1 11 1 1 11 1 1 11 1 1 1*/
- poj 3467
- poj 3467 Cross Counting
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- C++设计模式-----建造者模式\生成器模式
- 序列化和反序列化
- SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"问题解决
- 给TextView加边框
- memcached 的容易命令和Java 使用 memcached 的简单例子
- poj 3467
- 合并两个排序好的链表/链表去重/链式快排
- 项目总结——深入浅出socket网络编程
- 解决Failed to load class "org.slf4j.impl.StaticLoggerBinder"
- Servlet解决中文乱码问题
- Failed to load class "org.slf4j.impl.StaticLoggerBinder".问题解决
- 如何生成可执行的jar包文件
- Java程序如何生成Jar、exe及安装文件
- 关于打包java文件并生成可执行文件的问题