1176. Hyperchannels

博客介绍了1176. Hyperchannels,包含输入、输出及示例内容,文章转载自https://www.cnblogs.com/sdau--codeants/p/3260094.html 。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1176. Hyperchannels

Time limit: 1.0 second Memory limit: 64 MB
The Galaxy Empire consists of N planets. Hyperchannels exist between most of the planets. New Emperor urged to extend hyperchannels network in such a way, that he can move from any planet to any other using no more than one channel. One can pass through the channel only in one direction.
The last channel-establishing ship is located on the base near planet A. This ship can’t pass through the existing channel, it always establishes a new one. But presence of two channels connecting the same planets in one direction makes navigation too difficult, almost impossible. The problem is to find a route for this ship to establish all necessary channels with no excessive ones. In the end of this route ship should return to the base.

Input

First line contains integer N ≤ 1000 and number of the planet A (A  N) where the base is situated. Each of the following N lines contain N numbers, the j-th number of the i-th line equals to 1 if there exists channel from planet i to planet j, and equals to 0 otherwise. It is known, that Empire can fulfill its need of hyperchannels by establishing no more than 32000 new ones.

Output

Output should contain the sequence in which channels should be established. Each line should contain two integers — numbers of source and destination planet of channel. You may assume, that solution always exists.

Sample

inputoutput
4 2
0 0 1 0
0 0 1 0
1 1 0 1
0 0 1 0
2 4
4 1
1 2
2 1
1 4
4 2
Problem Author: Pavel Atnashev Problem Source: Third USU personal programming contest, Ekaterinburg, Russia, February 16, 2002
***************************************************************************************
深搜求欧拉回路并记录路径(注:vector   void   reverse(),根据实际重新计算vector容量,好用得加<algorithm>预处理!!!!!!!!!!!!!!!!!!!!)
***************************************************************************************
 1 #include<iostream>
 2 #include<string>
 3 #include<cstring>
 4 #include<cmath>
 5 #include<cstdio>
 6 #include<vector>
 7 #include<queue>
 8 #include<algorithm>
 9 using namespace std;
10 vector<int>adj[10001];
11 vector<int>path;
12 int n,m,i,j,k;
13 void  dfs(int s)//深搜求欧拉回路
14   {
15        while(adj[s].size())
16        {
17            int p=adj[s].back();
18            adj[s].pop_back();
19            dfs(p);
20 
21         }
22         path.push_back(s);//压入路径
23   }
24   int main()
25   {
26       cin>>n>>m;
27       for(i=1;i<=n;i++)
28        for(j=1;j<=n;j++)
29         {
30             cin>>k;
31             if(i!=j&&k==0)
32               adj[i].push_back(j);
33         }
34        dfs(m);
35        reverse(path.begin(),path.end());
36        for(i=0;i<path.size()-1;i++)
37         cout<<path[i]<<' '<<path[i+1]<<endl;
38        cout<<endl;
39        return 0;
40   }
View Code

 

转载于:https://www.cnblogs.com/sdau--codeants/p/3260094.html

资源下载链接为: https://pan.quark.cn/s/67c535f75d4c 最近我一直在忙于准备物联网STM32开发和实战演示的内容,还有小程序的编写,所以暂时没时间更新公众号。其实我原本打算在上一篇物联网平台使用系列文章后就告一段落了。不过,我在B站的一个粉丝私信我,希望我能录制一个关于MQTT上传图片的教程。于是,我今天整理了一下,写了个工具,并且准备分享一下实现思路。 我先用自己写的工具来演示上传图片的示例。首先,我在OneNET平台上创建了一个基于MQTT协议的产品和设备,然后进入数据流页面,此时页面上还没有任何数据。这里我假设你已经会用MQTT通过JSON格式上传数据了,如果你还不熟悉,可以先看看我之前的文章《OneNET物联网MQTT协议接入(下)——上传数据点》。 在物联网领域,OneNET是一个很常用的云平台,它支持多种API和协议,方便开发者把设备连接到云端,实现数据交互。今天主要讲的是如何通过MQTT协议把图片上传到OneNET平台。 MQTT是一种轻量级的通信协议,采用发布/订阅模式,特别适合物联网设备。在OneNET上,MQTT用于设备和平台之间的数据传输。要上传图片,首先要了解MQTT的基本概念和操作。 第一步是创建产品和设备。在OneNET平台上,你需要创建一个基于MQTT协议的产品,并在该产品下注册设备。产品定义设备的通用属性,设备则是数据的来源。 第二步是设置数据流和数据点。数据流是OneNET用来接收设备数据的通道,你可以创建多个数据流来接收不同类型的数据。数据点以JSON格式显示在数据流页面上。上传图片时,需要构造一个数据类型为2的payload数组,表示上传的是二进制数据。 第三步是构造payload。payload是MQTT消息体中的数据部分,对于图片上传,它需要包含图片的二进制数据。根据OneNET文档中的说明,你可以
资源下载链接为: https://pan.quark.cn/s/abbae039bf2a 在Java Spring框架中,动态配置定时任务是一项极具实用性的功能,它允许开发者根据实际需求灵活地调整或新增定时任务,而无需每次修改都重启应用。本文将详细探讨如何在Spring框架中实现动态定时任务配置,以及如何结合数据库来管理和更新这些任务。 Spring框架提供了@Scheduled注解,用于创建定时任务。通过在类或方法上使用该注解,可以定义一个定时执行的任务。例如,以下代码展示了如何使用@Scheduled注解定义一个每五分钟执行一次的任务: 然而,当任务的执行计划需要频繁更改时,将cron表达式硬编码到代码中并不是一个好的选择。此时,可以将定时任务的配置存储到数据库中,通过动态读取数据库中的定时规则来执行任务。为此,可以创建一个数据库表(如job_config),包含字段id、task_name、cron_expression等,用于存储任务的配置信息。 接下来,可以创建一个服务类,通过查询数据库获取定时任务的配置,并利用Spring的TaskScheduler接口来调度任务。TaskScheduler接口允许在运行时动态安排任务,而不仅限于应用启动时。以下是一个示例代码: 在上述代码中,scheduleTask方法用于添加或更新定时任务,rescheduleTask方法用于根据新的cron表达式调整任务,而unscheduleTask方法则用于取消任务。开发者需要根据实际的数据库操作逻辑和任务查找逻辑来完善这些方法。 在实际应用中,可以通过多种方式实现对数据库变更的监听。例如,可以使用JDBC的PreparedStatement和ResultSet进行查询,或者借助JPA、MyBatis等持久层框架来操作数据库。此外,可以通过消息队列(如RabbitMQ或Kafka)监听
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值