bzoj 4423: [AMPPZ2013]Bytehattan
发布日期:2021-05-06 23:49:06 浏览次数:22 分类:技术文章

本文共 1161 字,大约阅读时间需要 3 分钟。

题解

今天来学了一波平面图转对偶图。。

感觉很妙啊。。
但是我似乎并不能很好地认清平面图和对偶图
CODE:

#include
#include
#include
using namespace std;const int N=1505;int M;int f[N*N];int n,k;int m;int last=1;int find (int x){
return f[x]==x?f[x]:f[x]=find(f[x]);}int P (int x,int y){
return (x-1)*m+y;}void Ins (int x,int y)//这两个点连通 { int fx=find(x),fy=find(y); f[fx]=fy;}void solve (int x,int y,char ch){ int a,b; if (ch=='E') a=P(x+1,y),b=P(x+1,y+1); else a=P(x,y+1),b=P(x+1,y+1); int fx=find(a),fy=find(b); if (fx==fy) { last=0; printf("NIE\n"); } else { last=1; f[fx]=fy; printf("TAK\n"); }}int main(){ scanf("%d%d",&n,&k); m=n+1;M=m*m; for (int u=1;u<=M;u++) f[u]=u; for (int u=2;u<=m;u++) Ins(P(1,u),P(1,u-1)); for (int u=2;u<=m;u++) Ins(P(m,u),P(m,u-1)); for (int u=2;u<=m;u++) Ins(P(u,1),P(u-1,1)); for (int u=2;u<=m;u++) Ins(P(u,m),P(u-1,m)); while (k--) { int a,b,c,d;char ss[5],ss1[5]; scanf("%d%d",&a,&b);scanf("%s",ss); scanf("%d%d",&c,&d);scanf("%s",ss1); if (last==1) solve(a,b,ss[0]); else solve(c,d,ss1[0]); } return 0;}
上一篇:flask 404 not found
下一篇:flask error:TypeError: 'list' object is not callable

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2025年03月22日 05时42分09秒