设为首页 加入收藏

TOP

Codeforces 508D Tanya and Password
2015-07-20 17:22:16 来源: 作者: 【 】 浏览:3
Tags:Codeforces 508D Tanya and Password

题意:

n(10^5)个串每个串3个字符 两个串abc、xyz能拼在一起前提是b=x&&c=y 它们能拼成ab(x)c(y)z 求n个串品在一起的串

思路:

将串abc变成ab->bc的一条边 则原题变成了有向图的欧拉路径问题

有向图欧拉路径算法就是遍历 因为欧拉路径其实就是“每条边走一遍”

代码:

#include
  
   
#include
   
     #include
    
      #include
     
       #include
      
        #include
        #include
        
          #include
         
           #include
          
            #include
           
             #include
            
              #include
             
               using namespace std; typedef unsigned long long ULL; #define N 3850 int n,m; int in[N],out[N],Edge[N][N],ans[200010]; int get(char a){ if(a>='0'&&a<='9') return a-'0'; if(a>='A'&&a<='Z') return a-'A'+10; return a-'a'+36; } char put(int a){ if(a>=0&&a<=9) return '0'+a; if(a>=10&&a<=35) return 'A'+a-10; return 'a'+a-36; } void dfs(int x){ for(int i=0;i
              
               1){ can=0; break; }else if(tmp==1){ if(ed==-1) ed=i; else{ can=0; break; } }else if(tmp==-1){ if(st==-1) st=i; else{ can=0; break; } } } if(can){ if(st==-1){ for(int i=0;i
               
                =0;i--){ if(i!=m-1) printf("%c",put(ans[i]%62)); else printf("%c%c",put(ans[i]/62),put(ans[i]%62)); } puts(""); }else puts("NO"); } else puts("NO"); return 0; } 
               
              
             
            
           
          
         
        
      
     
    
   
  


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇UVa: 1595 - Symmetry 下一篇(hdu step 1.3.5)Fighting for HD..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·微服务 Spring Boot (2025-12-26 18:20:10)
·如何调整 Redis 内存 (2025-12-26 18:20:07)
·MySQL 数据类型:从 (2025-12-26 18:20:03)
·Linux Shell脚本教程 (2025-12-26 17:51:10)
·Qt教程,Qt5编程入门 (2025-12-26 17:51:07)