
信息奥赛一本通
iCrEjfuhhChXjVz
You got a dream, you gotta protect it. People can’t do something themselves, they wanna tell you you can’t do it. If you want something, go get it. Period.
爱学习
展开
-
01背包问题
01背包问题滚动数组优化#include <bits/stdc++.h>using namespace std;int a[100010];int b[100010];int dp[100010];int main(){ int m, n; cin >> m >> n; for(int i = 1; i <= n; i ++) { scanf("%d%d", &a[i], &b[i原创 2021-09-04 15:24:43 · 94 阅读 · 0 评论 -
信息奥赛题解目录T(部分答案)
信息奥赛题解目录T(部分答案)1.3.4 图论T1341 - 一笔画问题#define _CRT_SECURE_NO_WARNINGS#include <iostream>#include <cstdio>using namespace std;bool g[1010][1010];int c[1000010];int n, m;int pos = 0;int a[1000010];void dfs(int x){ for(int i = 1; i原创 2021-07-09 09:37:58 · 144 阅读 · 0 评论 -
ybt1351(拓扑排序)
#include<iostream>#include<cstdio>using namespace std;int a[101][101],c[101],r[101],ans[101];int i,j,tot,temp,num,n,m;int main() { cin >> n; for (i = 1; i <= n; i++) { do { cin >> j; if (j !=0 ) { c[i]++; a原创 2021-06-20 09:51:47 · 80 阅读 · 0 评论 -
01背包问题
#include<iostream>#include<cstdio>using namespace std;int a[101001],b[100010],dp[110100];int main(){ int n,m; scanf("%d%d",&m,&n); for(int i=1;i<=n;i++){ scanf("%d %d",&a[i], &b[i]); } for(int i=1;i<=n;i++){ f原创 2021-05-30 11:15:05 · 62 阅读 · 0 评论 -
ybt1253
#include<iostream>#include<cstdio>#include<queue>#include<cstring>using namespace std;int n,m;bool vis[1010][1010];int dx[]={1,2,2,1,-1,-2,-2,-1};int dy[]={2,1,-1,-2,-2,-1,1,2}; int a[1010][1010];struct P{ int x,y,step;}原创 2021-05-30 10:05:06 · 117 阅读 · 0 评论 -
ybt1337
1337:【例3-2】单词查找树时间限制: 1000 ms 内存限制: 65536 KB提交数: 6681 通过数: 3289【题目描述】在进行文法分析的时候,通常需要检测一个单词是否在我们的单词列表里。为了提高查找和定位的速度,通常都画出与单词列表所对应的单词查找树,其特点如下:1.根结点不包含字母,除根结点外每一个结点都仅包含一个大写英文字母;2.从根结点到某一结点,路径上经过的字母依次连起来所构成的字母序列,称为该结点对应的单词。单词列表中的每个单词,都是该单词查找原创 2021-05-15 08:16:08 · 129 阅读 · 0 评论 -
ybt1359: 围成面积
1359:围成面积时间限制: 1000 ms 内存限制: 65536 KB提交数: 6090 通过数: 2797【题目描述】编程计算由“*”号围成的下列图形的面积。面积计算方法是统计*号所围成的闭合曲线中水平线和垂直线交点的数目。如下图所示,在10×10的二维数组中,有“*”围住了15个点,因此面积为15。【输入】10×10的图形。【输出】输出面积。【输入样例】0 0 0 0 0 0 0 0 0 00 0 0 0 1 1 1 0 0 00 0 0 0 1 0原创 2021-05-14 18:11:38 · 614 阅读 · 0 评论 -
围圈报数
围圈报数有n个人依次围成一圈,从第1个人开始报数,数到第m个人出列,然后从出列的下一个人开始报数,数到第m个人又出列,…,如此反复到所有的人全部出列为止。设n个人的编号分别为1,2,…,n,打印出列的顺序。#include <iostream>#include <cstdio>#include <queue>using namespace std;int main(){ int n, m; scanf("%d%d", &n, &m);原创 2021-03-31 08:04:00 · 219 阅读 · 0 评论 -
ybt_1354
1354:括弧匹配检验时间限制: 1000 ms 内存限制: 65536 KB提交数: 18825 通过数: 6114【题目描述】假设表达式中允许包含两种括号:圆括号和方括号,其嵌套的顺序随意,如([ ]())或[([ ][ ])]等为正确的匹配,[( ])或([ ]( )或 ( ( ) ) )均为错误的匹配。现在的问题是,要求检验一个给定表达式中的括弧是否正确匹配?输入一个只包含圆括号和方括号的字符串,判断字符串中的括号是否匹配,匹配就输出 “OK” ,不匹配就输出“W原创 2021-03-21 14:03:33 · 147 阅读 · 0 评论 -
ybt_1002
ybt_1002#include <iostream>#include <cstdio>using namespace std;int main(void){ int a, b, c; cin >> a; cin >> a; cout << a; return 0;}原创 2021-03-21 09:42:12 · 135 阅读 · 0 评论 -
1323:【例6.5】活动选择
1323:【例6.5】活动选择题目描述学校在最近几天有n个活动,这些活动都需要使用学校的大礼堂,在同一时间,礼堂只能被一个活动使用。由于有些活动时间上有冲突,学校办公室人员只好让一些活动放弃使用礼堂而使用其他教室。现在给出n个活动使用礼堂的起始时间begini和结束时间endi(begini<endi),请你帮助办公室人员安排一些活动来使用礼堂,要求安排的活动尽量多。输入第一行一个整数n(n≤1000);接下来的n行,每行两个整数,第一个begini,第二个是endi(begini<en原创 2021-03-07 08:11:44 · 572 阅读 · 0 评论