zoukankan      html  css  js  c++  java
  • 111

    #include"stdio.h"
    #include"string.h"
    #include"iostream"
    using namespace std;
    const int M=41111;
    int f[M];
    struct st
    {
         int x,y;
    }node[M];
    int finde(int x,int L,char ch)
    {
         if(x!=f[x])
         {
              int t=f[x];
              f[x]=finde(f[x],L,ch);
              //printf("-->%d %d ",t,x);
              if(ch=='E')
              {
                   node[x].x=node[x].x+L;
                   node[x].y=node[x].y;
              }
              else if(ch=='W')
              {
                   node[x].x=node[x].x-L;
                   node[x].y=node[x].y;
              }
              else if(ch=='N')
              {
                   node[x].x=node[x].x;
                   node[x].y=node[x].y+L;
              }
              else if(ch=='S')
              {
                   node[x].x=node[x].x;
                   node[x].y=node[x].y-L;
              }


         }
         return f[x];
    }
    void make(int a,int b,int L,char ch)
    {
         int x=finde(a,L,ch);
         int y=finde(b,L,ch);
         if(x!=y)
         {
              f[y]=x;
              if(ch=='E')
              {
                   node[y].x=node[x].x+L;
                   node[y].y=node[x].y;
              }
              else if(ch=='W')
              {
                   node[y].x=node[x].x-L;
                   node[y].y=node[x].y;
              }
              else if(ch=='N')
              {
                   node[y].x=node[x].x;
                   node[y].y=node[x].y+L;
              }
              else if(ch=='S')
              {
                   node[y].x=node[x].x;
                   node[y].y=node[x].y-L;
              }
         }


    }
    int main()
    {
         int i,m,n,a,b,L;
         char ch[3];
         while(scanf("%d%d",&n,&m)!=-1)
         {
              for(i=1;i<=n;i++)
                   f[i]=i;
              while(m--)
              {
                   scanf("%d%d%d%s",&a,&b,&L,ch);
                   make(a,b,L,ch[0]);
              }
              for(i=1;i<=n;i++)
              printf("%d %d ",node[i].x,node[i].y);
         }
         return 0;

    }


  • 相关阅读:
    adb常用命令和工具
    playwright学习记录
    vue,element-ui表格,多个单元格值可修改(点击聚焦后变成input,失去焦点请求保存)
    vue,element-ui表格,合并单元格,如果需要合并的数据隔行,需要重新排列数组
    cas-5.3.x接入REST登录认证,移动端登录解决方案
    企业级cas5.3登录页面修改
    cas实现单点登录mysql,oracle双版本
    Mycat实现MySQL主从复制和读写分离(双主双从)
    IDEA安装插件后默认存放的位置
    值得推荐的Idea十几大优秀插件
  • 原文地址:https://www.cnblogs.com/mypsq/p/4348266.html
Copyright © 2011-2022 走看看