- 博客(60)
- 收藏
- 关注
原创 CCF CSP201812-4数据中心(c++100)
CCF CSP201812-4数据中心最小生成树克鲁斯卡尔模板题#include<iostream>#include<algorithm>using namespace std;const int maxn = 100010;struct Node{ int u,v,dis;}node[maxn];bool cmp(Node a, Node b){ return a.dis < b.dis;}int father[maxn*5];int f(int
2020-12-11 13:59:52 194
原创 CCF CSP202006-2Markdown渲染器(c++100)
CCF CSP202006-2Markdown渲染器stl操作分段落项目空行分别处理,有注释,附上测试用例,两种情况组合答案是25#include<string>#include<iostream>#include<vector>using namespace std;//一行文本最大数long long int maxtext; //存储文本vector<string>text; //去除首尾空格 void delSpace(stri
2020-12-10 12:57:33 361
原创 CCF CSP202009-3点亮数字人生(c++100)
CCF CSP202009-4星际旅行1、利用入度计算拓扑序列,不能拓扑序列就是有环,存储的点为输入为n,元器件为n+m2、根据拓扑序列计算每个元器件所需的输入的值3、输出相应元器件的值#include<bits/stdc++.h>using namespace std;const int maxn = 3010;vector<int>G[maxn],line,V[maxn];string op[maxn];int ans[10010][maxn],degree[m
2020-12-09 16:26:01 949 2
原创 CCF CSP201709-1打酱油(c++100)
CCF CSP201709-1打酱油先尽量5瓶再换3瓶的#include<iostream>using namespace std;int main(){ int n; cin>>n; n = n/10; int m = n; n += m/5 * 2; n += m%5/3; cout<<n<<endl; return 0;}
2020-12-08 18:56:04 201
原创 CCF CSP201709-2公共钥匙和(c++100)
CCF CSP201709-2公共钥匙和stl#include<iostream>#include<algorithm>#include<vector>using namespace std;struct Key{ int time,sno; bool flag;};vector<Key>key;bool cmp(Key a,Key b){ if(a.time == b.time){ if(a.flag == b.flag){
2020-12-08 18:50:32 271
原创 CCF CSP202009-2风险人群筛选(c++100)
CCF CSP202009-2风险人群筛选#include<iostream>using namespace std;int main(){ int n,k,t,xl,yl,xr,yr,ans1 = 0,ans2 = 0; cin>>n>>k>>t>>xl>>yl>>xr>>yr; for(int i = 0; i < n; i++){ int count = 0; bool flag1
2020-12-08 17:12:19 181
原创 CCF CSP202009-1称检测点查询(c++100)
CCF CSP202009-1称检测点查询#include#includeusing namespace std;struct Node{int x,y,dis;int sno;}node[210];bool cmp(Node a,Node b){if(a.dis == b.dis){return a.sno < b.sno;}return a.dis < b.dis;return 0;}int main(){int n,x,y;cin>>n>
2020-12-08 17:10:56 591
原创 CCF CSP202006-2稀疏向量(c++100)
CCF CSP202006-2稀疏向量#include<iostream>#include<map>using namespace std;map<int,int>mp;int main(){ int n,m1,m2; long long ans = 0; cin>>n>>m1>>m2; for(int i = 0; i < m1; i++){ int num1,num2; cin>>num1
2020-12-07 15:42:03 252
原创 CCF CSP202006-1线性分类器(c++100)
CCF CSP202006-1线性分类器#include<iostream>#include<vector>using namespace std;const int maxn = 1010;struct Point{ int x,y;}point;vector<Point>A,B;int main(){ int n,m; cin>>n>>m; for(int i = 0; i < n; i++){ char c;
2020-12-07 15:21:13 562
原创 CCF CSP201912-3化学方程式(c++80)
CCF CSP201912-3化学方程式思路:跟随测试用例规定一步步拿分并完善代码,没有处理9,10两个测试用例#include<iostream>#include<map>#include<string> using namespace std;map<string, int>lf,rt;int main(){ int n; cin>>n; cin.get(); while(n--){ lf.clear(); rt.
2020-12-06 16:04:17 211
原创 CCF CSP201912-2 回收站选址(c++100)
CCF CSP201912-2 回收站选址看测试用例约定发现暴力法并不会超时#include<iostream>#include<vector>using namespace std;struct Node{ int x,y;}node; vector<Node>G,V;int ans[5];int main(){ int n; cin>>n; for(int i = 0; i < n; i++){ cin>>n
2020-12-06 15:58:02 191
原创 CCF CSP201909-1报数(c++100)
CCF CSP201909-1报数#include<iostream>using namespace std;int arr[4];int main(){ int n,count = 0; cin>>n; while(n){ for(int i = 0; i < 4; i++){ count++; if(count % 7 == 0 ||count % 10 == 7 || count/10 % 10 == 7 || count/100 % 10
2020-12-06 15:35:57 299 1
原创 CCF CSP201903-2小明种苹果(续)c++100
CCF CSP201903-2附测试用例#include<iostream>using namespace std;bool drop[1010] = {false};int main(){ int n,D = 0,E = 0; long long int T = 0; cin>>n; for(int i = 0; i < n; i++){ int m,endNum,num,beginNum; bool flag = false; cin>&
2020-12-05 14:55:12 114
原创 CCF CSP201909-1小明种苹果(c++100)
CCF CSP201909-1小明种苹果#include<iostream>using namespace std;int main(){ int n,m; long long int ans = 0,maxi = 0,maxv = 0; cin>>n>>m; for(int i = 0; i < n; i++){ int num; long long int sum = 0; cin>>num; ans += num;
2020-12-05 14:07:14 165
原创 CCF CSP201903-1小中大(c++100)
CCF CSP201903-1小中大#include<iostream>#include<algorithm>#include<vector>#include<cstdio>using namespace std;const int maxn = 100010;long long int G[maxn];int main(){ long long int n,maxvalue,minvalue,midvalue; cin>>n
2020-12-04 15:18:18 332
原创 CCF CSP201903-2二十四点(C++100)
CCF CSP201903-2二十四点栈模拟#include<iostream>#include<stack>#include<string>#include<map>using namespace std;stack<int>number;stack<char>sign;map<char,int>mp;int deal(int num1, int num2, char c){ if(c == 'x'
2020-12-04 14:58:14 337
原创 CCF CSP201903-4消息传递接口(c++100)
CCF CSP201903-4消息传递接口思路看注释#include<iostream>#include<vector>#include<string>#include<cstring>using namespace std;const int maxn = 10010;vector<int>G[maxn];int send[maxn] = {0};int main(){ int T,n; cin>>T>
2020-12-04 13:46:58 338
原创 CCF CSP201812-2小明放学(c++100)
CCF CSP201812-2小明放学逻辑简单题#include<iostream>using namespace std;int main(){ long long int light[3], n, ans = 0; //r,g,y cin>>light[0]>>light[2]>>light[1]>>n; int sum = light[0] + light[1] + light[2]; for(int i = 0; i &
2020-12-03 16:23:16 312
原创 CCF CSP201812-1小明上学(c++100)
CCF CSP201812-1小明上学#include<iostream>using namespace std;int main(){ int r,g,y,n,ans = 0; cin>>r>>y>>g>>n; for(int i = 0; i < n; i++){ int num1,num2; cin>>num1>>num2; if(num1 == 2) num2 += r; else
2020-12-03 16:22:16 144
原创 CCF CSP201809-3元素选择器(c++100)
CCF CSP201809-3元素选择器注意点:标签不区分大小写多级选择只要等级比祖先低就可以采取贪心策略思路:用数组存以空格分隔的每个字符串按照要求依次匹配#include<iostream>#include<string>#include<vector>#include<set>#include<algorithm>using namespace std;struct Node{ int h;//几级属性 vect
2020-12-02 18:08:18 138
原创 CCF CSP201809-2买菜(c++100)
CCF CSP201809-2买菜#include<iostream>using namespace std;const int maxn = 1000010;int arr[maxn];int main(){ int n; cin>>n; for(int i = 0; i < 2 * n; i++){ int a,b; cin>>a>>b; for(; a < b; a++){ arr[a]++; } }
2020-12-02 15:13:30 240
原创 CCF CSP 201809-1卖菜(c++100)
CCF CSP 201809-1卖菜#include<iostream>using namespace std;const int maxn = 1010;int arr[maxn],b[maxn];int main(){ int n; cin>>n; for(int i = 1; i <= n; i++){ cin>>arr[i]; } for(int i = 1; i <= n; i++){ int num = 3; if
2020-12-02 15:05:07 88
原创 CCF CSP201803-2碰撞的小球(c++100)
CCF CSP201803-2碰撞的小球简单模拟#include<iostream>#include<cstring>#include<algorithm>using namespace std;struct Ball{ int point,v,sno;}ball[110];bool cmp1(Ball a,Ball b){ if(a.point == b.point) return a.sno < b.sno; return a.point
2020-12-01 18:05:14 281
原创 CCF CSP201803-1跳一跳(c++100)
CCF CSP201803-1跳一跳#include<iostream>using namespace std;int main(){ int n,ans = 0, num = 0; cin>>n; while(n != 0){ if(n == 1){ ans += n; num = 0; } else if(n == 2){ ans += n + num; num += 2; } cin>>n; } cou
2020-12-01 17:01:39 220
原创 CCF CSP201714-4行车路线(c++100)
CCF CSP201714-4行车路线思路:局部最优法,改写地杰斯特拉算法,把距离数组分成有无小路两部分#include<iostream>#include<vector>#include<cstring>#include<algorithm>using namespace std;const int maxn = 510,INF = 0x3fffffff;struct Point{ int v,cost,road;};vector&l
2020-11-30 19:56:13 322
原创 CCF CSP201712-2游戏(c++100)
CCF CSP201712-2游戏#include<iostream>#include<vector>using namespace std;int arr[1010];int main(){ int n,k,count = 0; //初始化,值为0表示出局 cin>>n>>k; for(int i = 0; i < n; i++){ arr[i] = 1; } int num = 0,index = 0; while(c
2020-11-30 15:14:37 267
原创 CCF CSP201712-1最小差值(c++100)
CCF CSP201712-1最小差值#include<iostream>#include<algorithm>using namespace std;int arr[1010];int main(){ int n,pre,ans = 0x3fffffff; cin>>n; for(int i = 0; i < n; i++){ cin>>arr[i]; } sort(arr,arr+n); for(int i = 1; i
2020-11-30 14:57:29 135
原创 CCF CSP201703-3MarkDown(c++100)
CCF CSP201703-3MarkDown思路:根据题目一种情况一种情况的解决,并根据测试用例分布慢慢设计得分#include<iostream>#include<vector>using namespace std;vector<string>V;\//行内结构处理void line(string &s){ int f1 = -1,f2 = -1; //超链接 int f3 = -1, f4 = -1; f1 = s.find('['
2020-11-29 14:19:21 313
原创 CCF CSP 201703-2学生排队(c++100)
CCF CSP 201703-2学生排队调stl#include<iostream>#include<vector>#include<algorithm>using namespace std;vector<int>G;int main(){ int n,m; cin>>n>>m; for(int i = 1; i <= n; i++){ G.push_back(i); } int pos,dis;
2020-11-29 12:40:29 329
原创 CCF CSP201703-1分蛋糕(c++100)
CCF CSP201703-1分蛋糕#include<iostream>using namespace std;int main(){ int n,k,num,value = 0,ans = 0; cin>>n>>k; for(int i = 0; i < n; i++){ cin>>num; value += num; if(value >= k){ ans++; value = 0; } } if(
2020-11-29 12:23:09 176
原创 CCF CSP 201612-3权限查询(c++100)
CCF CSP 201612-3权限查询按题意模拟,一层层嵌套,有注释#include<iostream>#include<map>#include<string>#include<algorithm>using namespace std;map<string,int>category,cy;map<string,map<string, int> >role;map<string,map<s
2020-11-29 12:14:30 202
原创 CCF CSP201609-3炉石传说(c++100)
CCF CSP201609-3炉石传说简单模拟#include<iostream>#include<string>using namespace std;struct Hero{ int attack,health;}A[8],B[7];int main(){ A[0].attack = B[0].attack = 0; A[0].health = B[0].health = 30; int n; cin>>n; bool flag = tru
2020-11-28 17:04:10 252
原创 CCF CSP201612-2工资计算(c++100)
CCF CSP201612-2工资计算#include<iostream>using namespace std;double tax[9] = {0,0.03,0.1,0.2,0.25,0.3,0.35,0.45};int taxMoney[9] = {0,1500,4500,9000,35000,55000,80000};int main(){ int S; cin>>S; if(S <= 3500) { cout<<S<<en
2020-11-28 16:07:55 392
原创 CCF CSP201612-1中间数(c++100)
CCF CSP201612-1中间数#include<iostream>#include<algorithm>using namespace std;const int maxn = 1010;int arr[maxn];int main(){ int n; cin>>n; bool flag = false; for(int i = 0; i < n; i++){ int num; cin>>num; arr[i] =
2020-11-28 15:26:14 153
原创 CCF CSP201604-3路径解析(c++100)
CCF CSP201604-3路径解析思路:根据题目依次处理,/…/就是删掉前一个目录#include<iostream>#include<string>#include<vector>using namespace std;vector<string>G;int main(){ int n; cin>>n; cin.get(); string cur,s; getline(cin,cur); for(int i = 0
2020-11-27 17:23:30 132
原创 CCF CSP201609-2 火车购票(c++100)
CCF CSP201609-2 火车购票简单模拟#include<iostream>using namespace std;int arr[20][5];int main(){ int n, num; cin>>n; for(int k = 0; k < n; k++){ cin>>num; bool flag = true; for(int i = 0; i < 20; i++){ int count = 0; fo
2020-11-27 16:25:55 241
原创 CCF CSP201609-1最大波动(c++100)
CCF CSP201609-1最大波动#include<iostream>#include<algorithm>using namespace std;int main(){ int n, pre, maxv = 0; cin>>n; for(int i = 0; i < n; i++){ int num; cin>>num; if(i == 0) pre = num; maxv = max(maxv, abs(num-p
2020-11-27 16:12:36 160
原创 CCF CSP201604-2 俄罗斯方块(c++100)
CCF CSP201604-2 俄罗斯方块思路:先消除需要插入的全为0的行,用size记录插入的行数,再从上往下遍历俄罗斯方块,遇到都为1就找到上一行为插入位置。#include<iostream>#include<vector>using namespace std;const int maxn = 16;vector<int>G[4];int arr[maxn][maxn];int size = 4;int main(){ int pos; f
2020-11-27 16:07:18 455
原创 CCF CSP201604-1折点计数(c++100)
CCF CSP201604-1折点计数#include<iostream>using namespace std;int main(){ int n,pre1,pre2,num,ans = 0; cin>>n; for(int i = 0; i < n; i++){ cin>>num; if(i == 0) pre1 = num; else if(i == 1) pre2 = num; else{ if((pre1 > pr
2020-11-27 15:03:05 151
原创 CCF CSP201512-3画图(c++100)
CCF CSP201512-3画图思路:把画布转成我们常用的形式,x,y转置,DFS换字符,注意:画线条的时候注意已经相交的情况#include<iostream>#include<algorithm>#include<string>using namespace std;const int maxn = 110;char arr[maxn][maxn];int m,n;int xx[4] = {-1,1,0,0};int yy[4] = {0, 0
2020-11-26 16:18:13 142
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人