好美的图论,真的 light up my life!题意: 给出一个只含有若干1,2,3的数列,我们可以两两交换数列元素;要求输出让这个数列不减的最小交换次数。 思路: 首先看起来很像冒泡.....然鹅要最少交换次数——显然不是模拟冒泡了。 开始用深搜来着,显然没办法剪枝,果断T掉。这个时候就要想一 ...
分类:
其他好文 时间:
2020-01-23 21:09:24
阅读次数:
59
根据题意,需要交换的部分会形成若干个不相交的环,独立处理每个环。 每个环可以用环内的最小值去和其它元素交换,或者用全局最小值和环上最小值交换,做一遍再交换回去。 #include <cstdio> #include <cstring> const int MOD = 9973; int m, n, ...
分类:
其他好文 时间:
2020-01-23 19:49:04
阅读次数:
60
基本思想: 没什么难的,水题,重点在于审题; 关键点: 无; #include<iostream> #include<stdlib.h> #include<stdio.h> #include<vector> #include<string> #include<math.h> #include<alg ...
分类:
其他好文 时间:
2020-01-23 12:39:56
阅读次数:
82
自己写的,少了异常处理。 #include <bits/stdc++.h> #include<math.h> #include <string> using namespace std; const int maxn = 100010; struct Node{//定义静态链表 int data; ...
分类:
其他好文 时间:
2020-01-19 09:19:21
阅读次数:
73
GitHub地址:https://github.com/hustcc/JS-Sorting-Algorithm 摘录一二: 1.冒泡排序 Python实现: def bubbleSort(arr): for i in range(1, len(arr)): for j in range(0, len ...
分类:
编程语言 时间:
2020-01-10 15:36:16
阅读次数:
69
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key ...
分类:
其他好文 时间:
2019-12-16 19:26:51
阅读次数:
77
原题链接在这里:https://leetcode.com/problems/pancake-sorting/ 题目: Given an array A, we can perform a pancake flip: We choose some positive integer k <= A.len ...
分类:
其他好文 时间:
2019-12-16 10:09:00
阅读次数:
112
思路: 首先把数组离散化,然后观察可以发现,在最优解中最终没有被移动过的那些数字一定是连续的,那么找到最长的连续的数字长度即可。 实现: ...
分类:
其他好文 时间:
2019-12-10 17:20:33
阅读次数:
125
Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test ...
分类:
其他好文 时间:
2019-12-02 00:47:23
阅读次数:
119
20182302 2019 2020 1 《数据结构与面向对象程序设计》实验7报告 课程:《程序设计与数据结构》 班级: 1823 姓名: 孙嘉伟 学号:20182302 实验教师:王志强 实验日期:2019年10月23日 必修/选修: 必修 1.实验内容 重构你的代码 把Sorting.java ...
分类:
其他好文 时间:
2019-11-17 23:39:27
阅读次数:
60