摘要:
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 阅读全文
摘要:
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; 阅读全文
摘要:
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]<<" 阅读全文
摘要:
problem solution //如果n为奇数,走满所有格须移动偶数次,n为偶数的话奇数次,然后少到一格少移动两次,奇偶性不改变,所以即可判断胜负。 codes #include<iostream> using namespace std; int main(){ int n; while(ci 阅读全文
摘要:
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 一、考虑补集: 阅读全文
摘要:
problem 有30000条队列,初始每条队列一条战舰,编号为1-30000。 给出T条指令,分为合并和询问,1、合并指令为: M i j 含义为第i号战舰所在的整个战舰队列,作为一个整体(头在前尾在后)接至第j号战舰所在的战舰队列的尾部。2、询问指令为: C i j 该指令意思是,询问电脑,第i 阅读全文
摘要:
problem solution codes //并查集及补集 //凡是与i+n节点在同一个集合里的,都是不能与i在同一个集合里的。 #include<iostream> #include<algorithm> using namespace std; struct Edge{ int u, v, 阅读全文
摘要:
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 阅读全文