1151 - Buy or Build

World Wide Networks (WWN) is a leading company that operates large telecommunication networks. WWN would like to setup a new network in Borduria, a nice country that recently managed to get rid of its military dictator Kurvi-Tasch and which is now seeking for investments of international companies (for a complete description of Borduria, have a look to the following Tintin albums King Ottokar's Sceptre",The Calculus Affair” and “Tintin and the Picaros”). You are requested to help WWN todecide how to setup its network for a minimal total cost.

Problem

There are several local companies running small networks (called subnetworks in the following) that partially cover the n largest cities of Borduria. WWN would like to setup a network that connects all n cities. To achieve this, it can either build edges between cities from scratch or it can buy one or several subnetworks from local companies. You are requested to help WWN to decide how to setup its network for a minimal total cost.

All n cities are located by their two-dimensional Cartesian coordinates.
There are q existing subnetworks. If q1 then each subnetwork c ( 1cq ) is defined by a set of interconnected cities (the exact shape of a subnetwork is not relevant to our problem).
A subnetwork c can be bought for a total cost wc and it cannot be split (i.e., the network cannot be fractioned).
To connect two cities that are not connected through the subnetworks bought, WWN has to build an edge whose cost is exactly the square of the Euclidean distance between the cities.
You have to decide which existing networks you buy and which edges you setup so that the total cost is minimal. Note that the number of existing networks is always very small (typically smaller than 8).

A 115 Cities Instance

Consider a 115 cities instance of the problem with 4 subnetworks (the 4 first graphs in Figure 1). As mentioned earlier the exact shape of a subnetwork is not relevant still, to keep figures easy to read, we have assumed an arbitrary tree like structure for each subnetworks. The bottom network in Figure 1 corresponds to the solution in which the first and the third networks have been bought. Thin edges correspond to edges build from scratch while thick edges are those from one of the initial networks.

Input

The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.

Each test case is described by one input file that contains all the relevant data. The first line contains the number n of cities in the country ( 1n1000 ) followed by the number q of existing subnetworks ( 0q8 ). Cities are identified by a unique integer value ranging from 1 to n . The first line is followed by q lines (one per subnetwork), all of them following the same pattern: The first integer is the number of cities in the subnetwork. The second integer is the the cost of the subnetwork (not greater than 2 x 106 ). The remaining integers on the line (as many as the number of cities in the subnetwork) are the identifiers of the cities in the subnetwork. The last part of the file contains n lines that provide the coordinates of the cities (city 1 on the first line, city 2 on the second one, etc). Each line is made of 2 integer values (ranging from 0 to 3000) corresponding to the integer coordinates of the city.

Output

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.

For each input file, your program has to write the optimal total cost to interconnect all cities.

Sample Input

1

7 3
2 4 1 2
3 3 3 6 7
3 9 2 4 5
0 2
4 0
2 0
4 2
1 3
0 5
4 4
Sample Output

17
Sample Explanation: The above instance is shown in Figure 2. An optimal solution is described in Figure 3 (thick edges come from an existing network while thin edges have been setup from scratch).

Figure 1: A 115 Cities Instance and a Solution (Buying the First and the Third Network)
这里写图片描述

Figure 2: The 7 City instance of the first sample input
这里写图片描述

Figure 3: An optimal solution of the 7 City instance in which which the first and second existing networkshave been bought while two extra edges (1 , 5) and (2, 4) have been setup
这里写图片描述
我有话说:
这道题比较裸,就是一个最小生成树。但是如果枚举选择的方案在进行prim或者kruskal算法。由于枚举量为2^q,给边排序需要的时间复杂度为n^2logn,而排序后每次kruskal算法的时间复杂度为n^2,所以最后的总时间复杂度你想想吧。
采取紫书上的优化策略。先求一次原图中的最小生成树。得到n-1条边。然后枚举完套餐后只考虑套餐和这n-1条边。因为,在最小生成树中,有一些边是不会进入的。那些已经属于同一个联通分量的边。所以只要那些在原来算法中被扔掉的边是不用考虑的。情况一,套餐中包含原来被扔掉的边,那么就只有购买套餐有可能使它们进入最小生成树,只要计算套餐和n-1条边即可。
情况二。套餐中完全不包含原来扔掉的边。那么就更不用考虑了。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
const int maxn=1000+10;
const int maxq=8;
int n;
int x[maxn],y[maxn],cost[maxq];
vector<int>subn[maxq];
int p[maxn];
int findest(int x){
    return p[x]==x?x:p[x]=findest(p[x]);
}
struct Edge{
   int u,v,d;
   Edge(int u,int v,int d):u(u),v(v),d(d){}
   bool operator < (const Edge& rhs)const{
        return d<rhs.d;
   }
};
int Kruskal(int cnt,const vector<Edge>& e,vector<Edge>& used)
{
    if(cnt==1)return 0;
    used.clear();
    int m=e.size();
    int ans=0;
    for(int i=0;i<m;i++){
        int u=findest(e[i].u),v=findest(e[i].v);
        int d=e[i].d;
        if(u!=v){
            p[u]=v;
            ans+=d;
            used.push_back(e[i]);
            if(--cnt==1)break;
        }
    }
    return ans;
}
int main() {
   int T,q;
   scanf("%d",&T);
   while(T--){
      scanf("%d%d",&n,&q);
      for(int i=0;i<q;i++){
         int cnt,u;
         scanf("%d%d",&cnt,&cost[i]);
         subn[i].clear();
         while(cnt--){
            scanf("%d",&u);
            subn[i].push_back(u-1);
         }
      }
      for(int i=0;i<n;i++)scanf("%d%d",&x[i],&y[i]);
      vector<Edge>e,need;
      for(int i=0;i<n;i++){
          for(int j=i+1;j<n;j++){
              int c=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
              e.push_back(Edge(i,j,c));
          }
      }
      for(int i=0;i<n;i++)p[i]=i;
      sort(e.begin(),e.end());
      int ans=Kruskal(n,e,need);
      for(int mask=0;mask<(1<<q);mask++){
          for(int i=0;i<n;i++)p[i]=i;
          int cnt=n,c=0;
          for(int i=0;i<q;i++)if(mask&(1<<i)){
              c+=cost[i];
              for(int j=1;j<subn[i].size();j++){
                  int u=findest(subn[i][j]),v=findest(subn[i][0]);
                  if(u!=v){p[u]=v;cnt--;}
              }
          }
          vector<Edge>dummy;
          ans=min(ans,c+Kruskal(cnt,need,dummy));
      }
      printf("%d\n",ans);
      if(T)printf("\n");
  }
  return 0;
}
Edit UVs & crop textures. 可编程渲染管线(SRP)兼容性 Unity可编程渲染管线(SRP)是让您能够通过C#脚本控制渲染的一个功能。SRP是支撑通用渲染管线(URP)和高清渲染管线(HDRP)的底层技术。 其他兼容性信息 Editor only. This is NOT for runtime use! 描述 Links: Manual Move, Rotate and Scale UVs with ease. And while you are at it you can also move your texture pixels along. Finally crop the texture and you are done. !! ⚠️ IMPORTANT ⚠️ !! Version 2 pack a lot of significant updates. Please delete to old version of the tool BEFORE installing this new version. 😎 Easy to use No need to do the cumbersone selection of many vertices. Simply paint on your mesh and all the painted triangles are selected. 💫 UV Editing Move, Rotate, Scale your UV howevery you like. The non-destructive workflow ensures all your original assets (meshes, materials, textures) are left untouched. The tool will generate and assign new ones automatically under Assets/UVEditorAssets/. 😺 Texture Editing The texture editing mode allows you to move pixels within your texture based on the selected triangles. Very handy to clean up messy layouts. And once you are done you can use the crop feature or trim the fat. Easy. 📚 Documentation Check out https://kamgam.com/unity/UVEditorManual.pdf ✔️ Full Source Code I publish this asset with full source code because as a developer I know how annoying it is to not have source code access. If you like it then please remind others to purchase the plugin. Don't just copy and paste it everywhere. Thank you ❤️ ✔️ Supports Unity 2021.3+, 2022, 2023, Unity 6, ... LTS It may work with earlier versions too but those are not tested anymore. 👇 Read this before you buy 👇 ⚠️ This is an EDITOR ONLY tool. It does not have runtime support. ⚠️ This is NOT a UV mapper tool. The tool can be used to EDIT existing UV layouts (see video) BUT if your model does not have UVs yet and needs a proper layout then this most likely is not the tool for it. ⚠️ Unity 2021.3 or higher is required (LTS releases strongly recommended). ⚠️ It may be slow on meshes with > 60.000 vertices. If you run into performance issues then please set the UV Filter to "Selected" to limit the UV display to the selection only. ✍️ Usage 1) To to Tools/UV Editor (or use the tools side bar) 2) Open the UV Editing Window 3) Select your Object and UVs 4) Move, scale or rotate them. 5) Hit "Apply" at the bottom of the UV Editor window. 6) Done. 😎 HINT 1: Editing single vertices is possible. Just select on of the adjacent triangles, switch to vertex mode and then delselect the vertices you do not want to move. 🧐 HINT 2: In crop mode notice that only the UVs that use the same texture are cropped. 🤠 HINT 3: Undo / Redo works only if the UV Editor window is focused (blue highlight at the top). ☎️ Support If you have any questions please write to office[at]kamgam.com. Please be patient, replies may take a few days. Please include your Asset Store Order Nr and the exact Unity version in your request. Please also try upgrading to the most recent LTS version before asking. Thank you. ❤️ If you like this asset then maybe you'll like these too: ⚙ Settings Generator One Settings UI + API for all render pipelines. ✂ Mesh Extractor 2 Separate your assets into useful parts within seconds. 🚧 Exclude from build Exclude any files and directories from build. 🏹 Power Pivot Edit, Rotate, Scale, Snap & Pivot Editor 我买了这个插件但是我不知道他什么意思 怎么使用
最新发布
04-03
<think>好的,我现在需要帮助用户理解他们购买的Unity插件“Edit UVs & crop textures”的功能和使用方法。用户已经购买了插件但不太明白它的作用和如何操作,所以我的回答需要详细且易于理解。 首先,用户提供的插件描述和说明里有很多技术细节,我需要将其简化,分步骤解释。同时,用户可能对UV编辑和相关术语不太熟悉,所以需要用通俗的语言解释概念,比如UV是什么,为什么需要编辑它们。 根据用户提供的信息,这个插件主要用于在Unity编辑器内调整模型的UV和纹理,属于非破坏性工作流,不会影响原始资源。兼容SRP,但仅限于编辑器使用,不支持运行时。需要注意版本要求(Unity 2021.3+),以及性能方面的注意事项,比如处理顶点数量多的网格可能会慢。 接下来,用户可能需要知道如何安装和基本使用步骤。安装部分需要提醒用户删除旧版本,避免冲突。使用步骤需要分点说明,例如打开工具窗口、选择物体、编辑UV、应用更改等。同时,用户提供的提示部分(如顶点编辑、裁剪模式、撤销功能)也需要整合到说明中,可能作为使用技巧或注意事项。 另外,用户可能遇到常见问题,比如性能慢,这时候需要指导他们如何调整UV Filter设置为“Selected”来优化。还要强调插件的限制,比如不能用于创建UV布局,只能编辑现有的,避免用户误解插件功能。 最后,提供支持联系方式,并鼓励用户参考官方文档,确保他们知道如何获取更多帮助。可能还需要提醒用户确保Unity版本符合要求,以及插件的适用场景,比如适合调整UV而非生成UV。 整体结构需要清晰,分部分解释功能、安装、使用步骤、技巧、注意事项和支持信息。避免使用过多技术术语,保持口语化,让用户逐步理解如何操作插件。</think>好的,我帮你整理一下这个插件的核心功能和使用方法: 📌 **插件核心功能**: 1. **UV编辑三件套**:移动(Move)、旋转(Rotate)、缩放(Scale)现有UV布局 2. **纹理像素调整**:通过选中UV区域直接移动纹理像素 3. **智能裁剪**:自动裁剪掉UV范围外的空白纹理区域 4. **非破坏性编辑**:自动生成新的材质和纹理副本(路径:Assets/UVEditorAssets/) ⚠️ **重要须知**: - 需要Unity 2021.3+(建议使用LTS版本) - 仅限编辑器使用,不支持运行时操作 - 非UV创建工具(需已有基础UV布局) - 建议顶点数 <6万(性能优化:UV Filter设为"Selected") 🎮 **使用步骤**: 1. 打开编辑器:`Tools > UV Editor` 或通过工具侧边栏 2. 选择需要编辑的模型对象 3. 使用笔刷工具涂抹选择要编辑的三角面 ![UV笔刷示意图](https://via.placeholder.com/300x200/FFD700/000?text=笔刷选择区域) 4. 切换操作模式: - `T键`:平移模式 - `R键`:旋转模式 - `S键`:缩放模式 5. 调整参数后点击"Apply"生成新材质 💡 **高级技巧**: 1. **顶点级编辑**: - 选择相邻三角面 → 切换顶点模式 → 取消选择不需要的顶点 2. **精准裁剪**: - 仅裁剪使用相同纹理的UV区域 - 建议先通过移动/缩放优化UV布局再裁剪 3. **撤销机制**: - 必须保持UV Editor窗口处于焦点状态(顶部蓝色高亮) - 快捷键:`Ctrl+Z` / `Ctrl+Y` 📦 **安装注意事项**: 1. 必须**先删除旧版本**再安装v2 2. 首次使用建议: ```bash Window > Rendering > UV Editor > 打开教学PDF ``` 3. 性能优化设置路径: `Edit > Project Settings > UV Editor > UV Filter设为Selected` 🛠 **典型应用场景**: 1. 修复UV拉伸:通过缩放模式调整局部UV密度 2. 纹理对齐:旋转UV使砖墙纹理水平对齐 3. 去除空白:裁剪掉打包后的多余透明区域 4. 局部调整:单独修正角色面部的UV扭曲 📞 **技术支持**: - 联系邮箱:office@kamgam.com - 需提供:Asset Store订单号 + 具体Unity版本 - 建议先尝试升级到最新LTS版本 💡 建议先使用一个简单立方体进行练习,观察UV变化与纹理的对应关系,熟悉后再处理复杂模型。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值