HNU校内训练 Skeletons Tehran 2016 反向建边

本文深入探讨了在游戏《垃圾部落》中实现成功攻击策略的算法。通过精心设计的图论算法,文章解决了如何确保所有骷髅兵在设定时间内准确摧毁目标村庄的问题,涉及到图的遍历、最短路径计算及复杂度分析。

抱歉没时间仔细讲解

,先mark一下,以后再更。

S

keletons

Time Limit: 10000ms, Special Time Limit:25000ms, Memory Limit:524288KB
Total submit users: 6, Accepted users: 1
Problem 14126 : No special judgement
Problem description

You have recently started your clan in the game of Trash of Clans. Each clan has several villages, and some one-directional roads each connecting two (not necessarily different) villages. Assume that all the roads have the same length. You can produce troops in your clan, and then attack another clan. Your favourite troops are wall breakers ? the skeletons that carry bombs, run and break walls of the enemy villages. The skeletons, like other troops in Trash of Clans, are smart and unpredictable.

During an attack you select the enemy clan, put one skeleton in every village of the enemy, choose a real positive value t for the bomb timers, and press the Attack key. Immediately, every skeleton randomly selects an arbitrary enemy village as the target such that each enemy village is the target of exactly one skeleton. Note that the starting and target village of a skeleton may be identical. All skeletons run at a constant and equal speed during the attack, without stop. They pass the roads in the correct direction and might pass a road several times. After exactly t seconds, a big bang happens and all skeletons explode.

An attack is successful if all skeletons can blow up their targets. The skeletons are so smart and each of them will choose a route to guarantee it will be at the target village exactly after t seconds, if such a route exists. Given a list of clans, your task is to determine the clans for which you can choose a timer value in order to guarantee the success of the attack. 

 
Input
There are multiple clan descriptions in the input. For each clan, the first line contains the number of villages n (1 ≤ n ≤ 50,000) and the number of roads m (1 ≤ m ≤ 100,000). The villages are numbered 1 through n. Each of the next m lines consists of two space-separated integers x and y denoting a one-directional road from village x to village y. There might be multiple roads connecting two villages, or some roads with identical start and end villages. The input terminates with a line containing 0 0 which should not be processed.

 
Output
For each clan write either the character “Y” denoting that you can choose a timer value t guaranteeing the success of every attack, or “N” otherwise.

 
Sample Input
9 10
1 2
2 3
3 4
4 5
5 1
4 6
6 7
7 8
8 9
9 3
3 3
1 2
2 3
1 3
0 0
Sample Output
Y
N
Problem Source
Tehran 2016
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<iomanip>
#include<cmath>
using namespace std;
const int maxn = 5e4+5;
struct node{
    int u,to;
}edge[maxn<<1][2];
int head[maxn][2], tail[maxn][2], dep[maxn][2], n, m, vis[maxn][2], cnt;

void add(int x, int y){
    cnt++;
    if (head[x][0]<0){
        head[x][0]=cnt;
    }
    edge[tail[x][0]][0].to=cnt;    edge[cnt][0].u=y;  edge[cnt][0].to=-1;    tail[x][0]=cnt;
    if (head[y][1]<0){
        head[y][1]=cnt;
    }
    edge[tail[y][1]][1].to=cnt;    edge[cnt][1].u=x;  edge[cnt][1].to=-1;    tail[y][1]=cnt;
    return ;
}

void dfs(int u, int zf){
    int k;
    for (int i=head[u][zf];i>0;i=edge[i][zf].to){
        k=edge[i][zf].u;
        if (k>0&&vis[k][zf]){
            vis[k][zf]=false;   dep[k][zf]=dep[u][zf]+1;
            dfs(k,zf);
        }
    }
    return ;
}

void read(){
    memset(dep,-1,sizeof(dep)); memset(tail,-1,sizeof(tail));   memset(head,-1,sizeof(head));   memset(vis,true,sizeof(vis));
    int j,k;
    cnt=0;
    for (int i=1;i<=m;++i){
        scanf("%d%d",&j,&k);
        add(j,k);
    }
    return ;
}
bool solve(){
    vis[1][0]=false;   vis[1][1]=false;
    dep[1][0]=dep[1][1]=1;
    dfs(1,0);   dfs(1,1);
    for (int i=1;i<=n;++i){
        if (dep[i][0]<0||dep[i][1]<0){
            return false;
        }
    }
    int ans=0;
    for (int i=1;i<=m;++i){
        ans=__gcd(ans,dep[edge[i][0].u][1]+dep[edge[i][1].u][0]-1);
    }
    if (ans==1){
        return true;
    }else{
        return false;
    }
}
int main(){
    while(~scanf("%d%d",&n,&m)){
        if (n==0){
            break;
        }
        read();
        if (solve()){
            puts("Y");
        }else{
            puts("N");
        }
    }
    return 0;
}

 

本 PPT 介绍了制药厂房中供配电系统的总体概念与设计要点,内容包括: 洁净厂房的特点及其对供配电系统的特殊要求; 供配电设计的一般原则与依据的国家/行业标准; 从上级电网到工厂变电所、终端配电的总体结构与模块化设计思路; 供配电范围:动力配电、照明、通讯、接地、防雷与消防等; 动力配电中电压等级、接地系统形式(如 TN-S)、负荷等级与可靠性、UPS 配置等; 照明的电源方式、光源选择、安装方式、应急与备用照明要求; 通讯系统、监控系统在生产管理与消防中的作用; 接地与等电位连接、防雷等级与防雷措施; 消防设施及其专用供电(消防泵、排烟风机、消防控制室、应急照明等); 常见高压柜、动力柜、照明箱等配电设备案例及部分设计图纸示意; 公司已完成的典型项目案例。 1. 工程背景与总体框架 所属领域:制药厂房工程的公用工程系统,其中本 PPT 聚焦于供配电系统。 放在整个公用工程中的位置:与给排水、纯化水/注射用水、气体与热力、暖通空调、自动化控制等系统并列。 2. Part 01 供配电概述 2.1 洁净厂房的特点 空间密闭,结构复杂、走向曲折; 单相设备、仪器种类多,工艺设备昂贵、精密; 装修材料与工艺材料种类多,对尘埃、静电等更敏感。 这些特点决定了:供配电系统要安全可靠、减少积尘、便于清洁和维护。 2.2 供配电总则 供配电设计应满足: 可靠、经济、适用; 保障人身与财产安全; 便于安装与维护; 采用技术先进的设备与方案。 2.3 设计依据与规范 引用了大量俄语标准(ГОСТ、СНиП、SanPiN 等)以及国家、行业和地方规范,作为设计的法规基础文件,包括: 电气设备、接线、接地、电气安全; 筑物电气装置、照明标准; 卫生与安全相关规范等。 3. Part 02 供配电总览 从电源系统整体结构进行总览: 上级:地方电网; 工厂变电所(10kV 配电装置、变压
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值