摘要: Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Description Given a positive integer n, write a program to find out a nonzero multiple m of 阅读全文
posted @ 2023-04-14 23:22 MarisaMagic 阅读(24) 评论(0) 推荐(0) 编辑
摘要: Fliptile Time Limit: 2000MS Memory Limit: 65536K Description Farmer John knows that an intellectually satisfied cow is a happy cow who will give more 阅读全文
posted @ 2023-04-14 20:43 MarisaMagic 阅读(13) 评论(0) 推荐(0) 编辑
摘要: Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Description Farmer John has been informed of the location of a fugitive cow and wants to catch 阅读全文
posted @ 2023-04-14 20:23 MarisaMagic 阅读(18) 评论(0) 推荐(0) 编辑
摘要: Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Description You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon 阅读全文
posted @ 2023-04-14 20:10 MarisaMagic 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 棋盘问题 Time Limit: 1000MS Memory Limit: 10000K Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行 阅读全文
posted @ 2023-04-14 19:53 MarisaMagic 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 背包问题 01背包问题 static const int N = 1010; int dp[N][N], v[N], w[N], n, c; int main(){ cin >> n >> c; for(int i = 1; i <= n; i ++ ) cin >> v[i]  阅读全文
posted @ 2023-04-14 13:45 MarisaMagic 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 树状数组 动态区间和询问 + 点修改 int lowbit(int x){ return x & -x; } void add(int x, int v){ for(int i = x; i <= n; i += lowbit(i)) tree[i] += v; } int query(int x) 阅读全文
posted @ 2023-04-14 13:27 MarisaMagic 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 拓扑排序 bool topo(){ queue<int> q; for(int u = 1; u <= n; u ++ ) if(!ind[u]) q.push(u); int cnt = 0; while(!q.empty()){ int u = q.front(); q.pop(); cnt + 阅读全文
posted @ 2023-04-14 13:23 MarisaMagic 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 递归实现枚举 递归实现指数型枚举 void dfs(int k){ if(k > n) { for(auto &x : res) cout << x << ' '; cout << endl; return; } dfs(k + 1); res.push_back(k); dfs(k + 1); r 阅读全文
posted @ 2023-04-14 01:05 MarisaMagic 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 模拟链表 单链表(链式前向星) void add_h(int x){ e[idx] = x, ne[idx] = h, h = idx ++ ; } //在第k个后面插入节点 void add(int k, int x){ e[idx] = x, ne[idx] = ne[k], ne[k] = i 阅读全文
posted @ 2023-04-14 00:55 MarisaMagic 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 排序 快速排序 线性时间选择 int partition(int l, int r){ int pos = rand() % (r - l + 1) + l; swap(a[pos], a[l]); int key = a[l], i = l, j = r; while(i != j){ while 阅读全文
posted @ 2023-04-14 00:47 MarisaMagic 阅读(28) 评论(0) 推荐(0) 编辑