「CF508A」Pasha and Pixels
题解
模拟染色,小范围暴力判断
标签是brute force。。。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<set> #include<ctime> #include<vector> #include<queue> #include<algorithm> #include<map> #include<cmath> #define eps 1e-8 #define inf 1000000000 #define pa pair<int,int> #define ll long long using namespace std; int read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,m,Q; bool mark[1005][1005]; bool jud(int x,int y) { for(int i=x-1;i<=x;i++) for(int j=y-1;j<=y;j++) if(mark[i][j]&&mark[i][j+1]&&mark[i+1][j]&&mark[i+1][j+1])return 1; return 0; } int main() { n=read();m=read();Q=read(); for(int i=1;i<=Q;i++) { int x=read(),y=read(); mark[x][y]=1; if(jud(x,y)){printf("%d\n",i);return 0;} } puts("0"); return 0; } |
Subscribe