上一页 1 ··· 5 6 7 8 9 10 11 12 下一页
摘要: 题目如下 We will consider the numbers 𝑎 and 𝑏 as adjacent if they differ by exactly one, that is, |𝑎−𝑏|=1. We will consider cells of a square matrix � 阅读全文
posted @ 2025-06-30 21:55 sirro1uta 阅读(24) 评论(0) 推荐(0)
摘要: 题目如下 Positive integer 𝑥 is called divisor of positive integer 𝑦, if 𝑦 is divisible by 𝑥 without remainder. For example, 1 is a divisor of 7 and 3 阅读全文
posted @ 2025-06-30 20:41 sirro1uta 阅读(16) 评论(0) 推荐(0)
摘要: C. Customs Controls 2 time limit per test2 seconds memory limit per test512 megabytes Look how short the statement is! This must be the easiest proble 阅读全文
posted @ 2025-06-21 00:22 sirro1uta 阅读(22) 评论(0) 推荐(0)
摘要: P3916 图的遍历 题目描述 给出 $N$ 个点,$M$ 条边的有向图,对于每个点 $v$,令 $A(v)$ 表示从点 $v$ 出发,能到达的编号最大的点。现在请求出 $A(1),A(2),\dots,A(N)$ 的值。 输入格式 第 $1$ 行 $2$ 个整数 $N,M$,表示点数和边数。 接下 阅读全文
posted @ 2025-06-10 00:20 sirro1uta 阅读(36) 评论(0) 推荐(0)
摘要: U279159 【图的存储】邻接矩阵无向图 题目描述 一个国家有n个城市编号为1至n,被已有的m条高速公路连接。现在政府决定建造新的高速公路,有q项提议,每项提议计划在x,y城市间建造一条新的高速公路。当然有些提议中某两个城市间可能已经存在高速公路了,那么这项提议将会取消,反之则会通过 输入格式 第 阅读全文
posted @ 2025-06-08 00:09 sirro1uta 阅读(20) 评论(0) 推荐(0)
摘要: H. Optimize DFS time limit per test3 seconds memory limit per test256 megabytes You are given a tree with 𝑛 vertices. Every vertex 𝑣 has two values 阅读全文
posted @ 2025-06-05 00:34 sirro1uta 阅读(14) 评论(0) 推荐(0)
摘要: 一个典例 点击查看代码 #include <stdio.h> #include <algorithm> #define MAXN 100005 int visited[MAXN]; int queue[MAXN]; int graph[MAXN][MAXN]; void bfs(int u, int 阅读全文
posted @ 2025-06-03 00:21 sirro1uta 阅读(9) 评论(0) 推荐(0)
摘要: 题目描述 这是一道模板题。 给一棵有根树,这棵树由编号为 1\dots N 的 N 个结点组成。根结点的编号为 R。每个结点都有一个权值,结点 i 的权值为 v_i。 接下来有 M 组操作,操作分为两类: 1 a x,表示将结点 a 的权值增加 x; 2 a,表示求结点 a 的子树上所有结点的权值之 阅读全文
posted @ 2025-06-02 01:13 sirro1uta 阅读(15) 评论(0) 推荐(0)
摘要: 题目在这 https://codeforces.com/contest/1044/problem/F 很基础的题目适合我 慢慢来 已经在输入给了树构造的细节,所以我们不需要构造树了,只要判断构造完交换位置后是否能满足dfs 关键代码 点击查看代码 int is_valid_dfs(int n) { 阅读全文
posted @ 2025-05-27 00:46 sirro1uta 阅读(25) 评论(0) 推荐(0)
摘要: U410472 【模板】dfs序 题目背景 关于 dfs 序是访问一棵树时将其按照 dfs 时访问的先后顺序打上序号。于是,通过 O(n) 的扫一遍树上的每个点就可以把非线性的树形结构转成线性的区间结构。 题目描述 给定一颗树,输出这棵树的dfs序,并且输出dfs的入时间戳和出时间戳。根节点默认为1 阅读全文
posted @ 2025-05-25 00:33 sirro1uta 阅读(21) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 下一页