摘要:
题意:给一个数列,两个栈,要求数列从后往前依次入栈,问能否使出栈序列是不减的。(双栈排序)分析:利用二分图染色法。首先观察那些牌绝对不能压入同一个栈,若两个不能入同一栈则连一条边,然后根据二分图染色,看是否能构成二分图。如果不能直接输出impossible两张牌i,j不能入同一栈的充要条件是,i>j>k(i最先入栈) && stock[k]<stock[i]<stock[j]然后根据每个点所染的颜色决定把每个牌压入哪个栈。然后模拟即可。View Code #include <iostream>#include <cstdio>#i 阅读全文
posted @ 2011-08-01 20:32
undefined2024
阅读(302)
评论(0)
推荐(1)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;struct Point{ long long x, y;}first, last, now;int n;void input(){ printf("%d ", n); scanf("%lld%lld", &first.x, &first.y); last = first; for ( 阅读全文
posted @ 2011-08-01 16:07
undefined2024
阅读(420)
评论(0)
推荐(0)
摘要:
注意要用c++,精度问题注意有负数答案View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;#define maxn 35#define eps 10e-9int map[maxn * maxn];int n, m;double water, least;int dblcmp(double a, double b){ if (fabs(a - b) < 阅读全文
posted @ 2011-08-01 15:25
undefined2024
阅读(350)
评论(0)
推荐(0)
摘要:
题意:本题要求把一堆物品分成两堆,两堆总重量相差不到百分之2,即把物品进行背包,试着能否构成sum/(1 + 1.02)到sum/(1 + 1.02) * 1.02之间的一个数。分析:背包搜索,当要从若干个物品中选出一些的时候,每次递归最好不要单纯地枚举第i个物品是要还是不要,而是要用一个循环从上一个要的物品开始去枚举下一个物品要第几个。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>usingnamespace std;#defi 阅读全文
posted @ 2011-08-01 14:18
undefined2024
阅读(698)
评论(0)
推荐(0)
摘要:
简单题注意有两个相同单词相邻的情况View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxl 20char st[2][maxl];int main(){ //freopen("t.txt", "r", stdin); int sum = 0; int i = 0; st[1][0] = '\0'; while (scanf 阅读全文
posted @ 2011-08-01 10:46
undefined2024
阅读(453)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;char st[50];bool v(char a){ return a =='a' ||a =='e' ||a =='i' ||a =='o' ||a =='u';}bool accept(){ int n = strlen(st); bool found = 阅读全文
posted @ 2011-08-01 10:16
undefined2024
阅读(182)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 25int n, m, blow, power[maxn];bool on[maxn];void out(int a){ int b = m - a - 1; int x; for (int i = 0; i < b; i++) scanf("%d", &x);}void inpu 阅读全文
posted @ 2011-08-01 10:03
undefined2024
阅读(310)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;char st[30];int target;void work(){ int len = strlen(st); for (int i = len; i >= 0; i--) for (int j = len; j >= 0; j--) if (i != j) for (in 阅读全文
posted @ 2011-08-01 09:49
undefined2024
阅读(521)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 10005int n;int dice[maxn][10];int opp[7] ={ 5, 3, 4, 1, 2, 0 };void input(){ scanf("%d", &n); for (int i = 0; i < n; i++) for (int j = 0; j & 阅读全文
posted @ 2011-08-01 09:19
undefined2024
阅读(161)
评论(0)
推荐(0)

浙公网安备 33010602011771号