【C语言】 双栈排序问题
题目如下:
经典的双栈排序问题,题目很简单但是实现却很难,花了很久的时间想这道题,最后看到了一个二分图染色法的思路,最终终于解决了,二分图染色法:https://blog.csdn.net/linwh8/article/details/52606751
话不多说,直接上代码
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define MAX 1003
bool picture[MAX][MAX]; // bipartite graph
int color[MAX]; // The color of elements
int temp[MAX];
int small[MAX]; // An array use for judge whether the two numbers obey the rule
int num; // The number of elements we want to enter
bool flag; // Make up whether the string of number can fit into two£stack sort
void set_color(int i, int c){
color[i] = c;
for (int j = 0; j < num; j++) {
if (picture[i][