摘要: problem There are nn cities numbered from 11 to nn, and n−1n−1 roads connecting these nn cities, i.e., it is a tree with nn nodes. Each road takes 11  阅读全文
posted @ 2021-11-16 09:41 _gwj1139177410 阅读(51) 评论(0) 推荐(0)
摘要: problem 给你一个原始的分形图 t组数据,对于每组数据,输入3个数n,h,o (n为在第n级,h,o为两个房子的编号) 求在第n级情况下,编号为h和o的两个点之间的距离*10为多少 其中,第n级分形图形成规则如下:1. 首先先在右下角和右上角复制一遍n-1情况下的分形图2. 然后将n-1情况下 阅读全文
posted @ 2021-11-15 15:26 _gwj1139177410 阅读(102) 评论(0) 推荐(0)
摘要: problem solution codes //c[i]:第i行的皇后放在第几列 #include<iostream> using namespace std; int n, c[20], ans; void dfs(int cur){ if(cur > n)ans++; else for(int 阅读全文
posted @ 2021-11-15 15:25 _gwj1139177410 阅读(32) 评论(0) 推荐(0)
摘要: problem solution codes #include<iostream> #define mod 6662333 using namespace std; typedef long long LL; LL dfs(LL a, LL b, LL p){ if(b==1)return a%p; 阅读全文
posted @ 2021-11-15 15:24 _gwj1139177410 阅读(29) 评论(0) 推荐(0)
摘要: problem solution codes #include<iostream> using namespace std; int n, c[20]; void dfs(int cur){ if(cur == n){ for(int i = 0; i < n; i++)cout<<c[i]<<" 阅读全文
posted @ 2021-11-15 15:24 _gwj1139177410 阅读(52) 评论(0) 推荐(0)
摘要: problem solution //如果n为奇数,走满所有格须移动偶数次,n为偶数的话奇数次,然后少到一格少移动两次,奇偶性不改变,所以即可判断胜负。 codes #include<iostream> using namespace std; int main(){ int n; while(ci 阅读全文
posted @ 2021-11-15 15:18 _gwj1139177410 阅读(21) 评论(0) 推荐(0)
摘要: problem 森林中有3种动物:A吃B,B吃C,C吃A 现有 N 个动物(编号1~n),K句话。1、1 X Y,表示 X 和 Y 是同类。2、2 X Y,表示 X 吃 Y。 一句话是假话当且仅当:1、与前面的冲突。2、X吃X。3、编号大于N。 判断当前话的真假。 solution 一、考虑补集: 阅读全文
posted @ 2021-11-15 15:16 _gwj1139177410 阅读(36) 评论(0) 推荐(0)
摘要: problem 有30000条队列,初始每条队列一条战舰,编号为1-30000。 给出T条指令,分为合并和询问,1、合并指令为: M i j 含义为第i号战舰所在的整个战舰队列,作为一个整体(头在前尾在后)接至第j号战舰所在的战舰队列的尾部。2、询问指令为: C i j 该指令意思是,询问电脑,第i 阅读全文
posted @ 2021-11-15 15:15 _gwj1139177410 阅读(36) 评论(0) 推荐(0)
摘要: problem solution codes //并查集及补集 //凡是与i+n节点在同一个集合里的,都是不能与i在同一个集合里的。 #include<iostream> #include<algorithm> using namespace std; struct Edge{ int u, v, 阅读全文
posted @ 2021-11-15 15:14 _gwj1139177410 阅读(74) 评论(0) 推荐(0)
摘要: problem solution codes //并查集模板 #include<iostream> using namespace std; int fa[5010]; void init(int n){for(int i = 1; i <= n; i++)fa[i]=i;} int find(in 阅读全文
posted @ 2021-11-15 15:13 _gwj1139177410 阅读(34) 评论(0) 推荐(0)