CCF CSP
SXxtyz
这个作者很懒,什么都没留下…
展开
-
CCF元素选择器
思路fat数组保存其直接祖先#include <bits/stdc++.h>using namespace std;const int maxn = 105;int n, m, fat[maxn], dot[maxn];string name[maxn], label[maxn], line, s;int main() { scanf("%d %d\n", &n, &m); for(int i = 1; i <= n; i++) {...原创 2021-03-16 20:38:01 · 125 阅读 · 0 评论 -
JSON解析CCF
思路先对输入的json文件进行预处理,去掉(不包含在引号里的)空格、引号、逗号、冒号等字符,将其以空格代替,然后根据利用stringstream处理即可(虽然stringstream速度很慢,但是刷CCF足够)。#include <bits/stdc++.h>using namespace std;int n, m, in;string s, json = "哈哈哈哈 ", tmp;unordered_map<string, string> hp;vector<..原创 2021-03-13 21:00:08 · 69 阅读 · 0 评论 -
CCF节日
思路强行模拟,计算1849年的12月31日开始,至year年的a月是第多少天(因为1949年的12月31日是周一,所以不从1850年的1月1日开始算,a的含义见题意)。#include <bits/stdc++.h>using namespace std;int a, b, c, x, y, days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};int leap(int n) { return n % 400.原创 2021-03-12 17:15:52 · 69 阅读 · 0 评论 -
CCF公共钥匙盒
思路模拟,没什么好说的,用set将每个可能会进行收放的时刻记录,最后判断每个时刻即可,注意是先放后拿#include <bits/stdc++.h>using namespace std;const int maxn = 1005;set<int> tim, st;int n, k, pos[maxn], state[maxn], w[maxn], s[maxn], c[maxn];int main() { scanf("%d %d", &n, &a..原创 2021-03-12 10:58:20 · 77 阅读 · 0 评论 -
CCF碰撞的小球
思路暴力模拟,没什么好说的#include <bits/stdc++.h>using namespace std;const int maxn = 105;struct node { int step = 1, now;} a[maxn];int n, L, t;int main() { scanf("%d %d %d", &n, &L, &t); for(int i = 1; i <= n; i++) scanf("%...原创 2021-03-12 01:34:14 · 62 阅读 · 0 评论 -
CCF小明放学
思路(我怕不是个废物,交通规则都不懂,写了一个小时一直WA,后来发现自己把交通规则搞错了)红绿灯的循环顺序为绿黄红,也可以写成黄红绿、红绿黄,写成绿黄红比较方便。每次循环以刚跳到绿灯时刻为000时刻,所以举例:假设绿灯持续303030秒、黄灯333秒、红灯303030秒时,第181818秒是绿灯,第313131秒是黄灯,第545454秒是红灯,第83≡20mod (30+3+30)83\equiv 20\mod(30+3+30)83≡20mod(30+3+30)秒是绿灯,依次类推。在每一个红绿..原创 2021-03-12 00:54:24 · 144 阅读 · 0 评论 -
CCF二十四点
思路方法一:非栈做法,加减法运算优先级相同,可以看做一种运算,乘除法同理,则最多一共判断2×2×2=82\times2\times2=82×2×2=8种情况#include <iostream>using namespace std;int n, a, b, c, d;char x, y, z;bool is_add(char m) { return m == '+' || m == '-';}int solve(int m, char op, int n) { ...原创 2021-03-11 18:46:59 · 119 阅读 · 0 评论 -
CCF买菜
思路方法一:归并排序的改造,遇到不相交区间时直接相加,否则依次递增寻找相交子区间长度#include <iostream>using namespace std;const int maxn = 2005;struct node { int x, y;} a[maxn], b[maxn];int n, ans;int main() { scanf("%d", &n); for(int i = 1; i <= n; i++) scanf(".原创 2021-03-11 17:59:57 · 120 阅读 · 0 评论 -
CCF小明种苹果(续)C++
思路简单模拟即可#include <iostream>using namespace std;const int maxn = 1005;int now, flag[maxn], N, m, T, D, E;int main() { scanf("%d", &N); for(int i = 0; i < N; i++) { scanf("%d %d", &m, &now); for(int j = ...原创 2021-03-11 13:53:47 · 65 阅读 · 0 评论 -
风险人群筛查C++简单模拟
思路:写一个判断是否在矩形内的函数,只需要判断再矩形外取反即可对每一组数据进行判断,设置标志位has_in,判断某个人是否已经被统计过,如果存在在矩形内的点,且还未被统计(标志位为0),则pass++,且标志位置为1设置标志位has_stay,判断某个人是否已经逗留,在矩形内时将s值自增1,如果s值大于阈值k且has_stay=0,则stay++,且将标志位置为0时间复杂度O(nt)O(nt)O(nt),空间复杂度O(1)O(1)O(1)#include <bits/stdc++....原创 2021-03-09 12:20:06 · 185 阅读 · 0 评论 -
CCF认证期末预测之最佳阈值
期末预测之最佳阈值题目描述具体来说,顿顿评估了mmm位同学上学期的安全指数,其中第i(1≤i≤m)i(1\le i\le m)i(1≤i≤m)位同学的安全指数为yiy_iyi,是一个[0,108][0,10^8][0,108]范围内的整数;同时,该同学上学期的挂科情况记作resulti∈{0,1}result_i\in \{0,1\}resulti∈{0,1},其中000表示挂科、111表示未挂科。相应地,顿顿用predictθ(y)predict_{\theta}(y)predictθ(y)表原创 2021-03-08 23:56:11 · 430 阅读 · 0 评论