IDEA2022如何创建web项目
2023-09-14 09:14:24 时间
IDEA2022如何创建web项目
简介:本文讲解最新版的IDEA2022如何创建web项目。
第一步
点击File->New->Project->New Project
第二步
输入项目名称Name
输入项目路径:Location
Build system选择Maven
选择jdk版本
点击创建Create
第三步
点击Add Framework Support
合并集合
一共有 n 个数,编号是 1∼n,最开始每个数各自在一个集合中。
现在要进行 m 个操作,操作共有两种:
M a b,将编号为 a 和 b 的两个数所在的集合合并,如果两个数已经在同一个集合中,则忽略这个操作;
Q a b,询问编号为 a 和 b 的两个数是否在同一个集合中;
输入格式
第一行输入整数 n 和 m。
接下来 m 行,每行包含一个操作指令,指令为 M a b 或 Q a b 中的一种。
输出格式
对于每个询问指令 Q a b,都要输出一个结果,如果 a 和 b 在同一集合内,则输出 Yes,否则输出 No。
每个结果占一行。
数据范围
1≤n,m≤105
输入样例:
4 5
M 1 2
M 3 4
Q 1 2
Q 1 3
Q 3 4
输出样例:
Yes
No
Yes
提交代码
#include<iostream>
using namespace std;
const int N = 100010;
int n, m;
int p[N];
int find(int x) // 找到x的祖先节点
{
if (p[x] != x) p[x] = find(p[x]);
return p[x];
}
int main()
{
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; ++i) p[i] = i;
while (m--)
{
char op;
int a, b;
scanf (" %c%d%d", &op, &a, &b);
if (op == 'M') p[p[find(a)]] = find(b); // 让a的祖先节点指向b的祖先节点
else
{
if (find(a) == find(b)) puts("Yes");
else puts("No");
}
}
return 0;
}
import java.io.*;
public class Main
{
static int N = 100010;
static int n, m;
static int [] p = new int [N];
static int find(int x)
{
if (p[x] != x) p[x] = find(p[x]);
return p[x];
}
public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader (System.in));
String [] str = reader.readLine().split(" ");
n = Integer.parseInt(str[0]);
m = Integer.parseInt(str[1]);
for (int i = 1; i <= n; ++ i) p[i] = i;
while (m -- > 0)
{
String op;
int a, b;
str = reader.readLine().split(" ");
op = str[0];
a = Integer.parseInt(str[1]);
b = Integer.parseInt(str[2]);
if (op.equals("M")) p[find(a)] = find(b);
else
{
if (find(a) == find(b)) System.out.println("Yes");
else System.out.println("No");
}
}
}
}
相关文章
- 这些年我开源的几个小项目
- idea如何运行Java Web项目(Servlet、JSP)
- IntelliJ IDEA创建maven web项目(IDEA新手适用)
- web安全色_WEB标准颜色
- Web阶段:第二十一章:图书商城项目
- IDEA运行web项目需要的一些配置(tomcat,maven)
- 手动部署java项目到k8s中
- springboot详细讲解_Springboot项目
- 使用 centerOS 7 部署 django 项目 python3.7.3
- 推荐一款工作流项目,好用到爆!
- vue.js客服系统实时聊天项目开发(三)实现对话框聊天界面
- java中使用idea部署tomcat项目详细流程(java web)
- 小型Web项目,团队成员之间应该如何进行协作?
- SSM项目中单元测试的配置
- 前端项目运行常见问题
- JavaWeb项目导入MyEclipse后变为JAVA项目项目【解决方法】详解程序员
- 服务快速配置Linux下的Web服务(linux配置web)
- 简单易行:使用Web连接MySQL数据库(web连接mysql数据库)
- 服务器快速安装Linux下的Web服务器(linux安装web)
- Linux下搭建完美Web服务器配置(linux配置web服务器)
- 器重启Web服务器:Linux下的快速操作(linux重启web服务)
- 深入学习Linux项目,获取丰富的经验(linux项目经验)
- Firefox OS加入Cordova项目 web应用开发更简单
- 管理MSSQL的好帮手:在线Web管理器来帮忙!(在线web管理mssql)
- Web项目利用Redis提高效率(web项目加入redis)
- web项目快速部署之Redis配置指南(web项目redis配置)
- Web页面优化Redis的应用示范(web页面redis)
- Web项目下使用Redis加速优化(web项目 redis)
- Web查找Redis明智之行(web如何查找redis)
- Web与Redis哪一种优胜(web和redis哪种好)