摘要:
题目链接:https://www.luogu.com.cn/problem/P7074 一、dfs(25分)没有任何优化,时间复杂度约(O(3^(n*m))) 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m; 4 int a[1 阅读全文
摘要:
本题第一难点:字符串处理 方法一:纯模拟,时间复杂度O(q*|s|)~估计分数30左右 1 #include<bits/stdc++.h> 2 using namespace std; 3 char s[1000010]; 4 char c; 5 int len; 6 int n, a[100010 阅读全文
摘要:
题目链接:https://www.luogu.com.cn/problem/P7072 方法一:50分代码(时间复杂度为n*nlongn) 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, w, a[100010], b[100010 阅读全文
摘要:
方法一:模拟 1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n; 6 cin>>n; 7 if(n%2==1) 8 cout<<-1; 9 else{ 10 while(n>0){ 11 int p=1 阅读全文
摘要:
CCF2020 CSP-j2第二题 https://www.luogu.com.cn/problem/P5661 方法一:纯模拟(40分) 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, bs[100005], p[100005], 阅读全文
摘要:
题目链接https://www.luogu.com.cn/problem/P1160 很裸的一道队列的题 方法一:没审清题目,,直接就来写,笨笨得每次都扫描一遍链表导致TLE,最后得分40分 1 #include<bits/stdc++.h> 2 using namespace std; 3 int 阅读全文
摘要:
题目链接https://www.luogu.com.cn/problem/P1083 一、5分题解: 1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 cout<<0; 6 return 0; 7 } View C 阅读全文
摘要:
题目链接https://www.luogu.com.cn/problem/P3406 【解题思路】前缀和、查分 对于其中一小段,我们要么全部买纸票,要么全部刷卡。 所以我们只需要统计每一小段经过的总次数。 如果你暴力模拟统计的话,估计会tle。 怎么快速知道每一段次数呢? 我们回忆一下“借教室”这道 阅读全文
摘要:
题目链接https://www.luogu.com.cn/problem/P3397 题目数据很水,但是差分的模版题 方法一:模拟 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m; 4 int sx, sy, ex, ey; 5 阅读全文
摘要:
【问题描述】 给出一个n*m的矩阵,多次询问子矩阵中数字之和。 【输入格式】 第一行包含三个正整数n, m, k(n, m<=5000, k<=10000),分别表示矩阵行数和列数以及询问次数。 接下来的n行,每行包含m个整数(整数不超过10000),描述该矩阵。 接下来的k行询问,数据描述子矩阵左 阅读全文
摘要:
链接:https://www.luogu.com.cn/problem/P1115 方法一:0分代码 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, a[210000]; 4 int ans=-(1<<30); 5 int sum( 阅读全文
摘要:
先把如下代码熟悉,再学习BFS的框架 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxN=100; 4 int que[maxN];//定义数组模拟队列 5 int f, r;//队首队尾信息 6 int n;//输入数 阅读全文
摘要:
http://ybt.ssoier.cn:8088/problem_show.php?pid=1219 1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 int t;//表示输入t组数据 5 int n, m;//棋盘大小 阅读全文
摘要:
http://ybt.ssoier.cn:8088/problem_show.php?pid=1361 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int M=20; 4 int n,k,a[M],b[M]; 5 bool fla 阅读全文
摘要:
http://ybt.ssoier.cn:8088/problem_show.php?pid=1362 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, k;//按要求输入 4 int a, b;//按要求输入 5 int rel[1 阅读全文