Luogu
_sophon
Brooding renders me prophetic
展开
-
Luogu P1115 最大子段和
最大子段和#include <bits/stdc++.h>using namespace std;int num,number[200005],max_prefix_subsegment[200005],prefix_sum[200005],min_prefix_sum=0,max_subsegment=-1e7;int main(){ ios::sync_wit...原创 2019-02-09 20:07:02 · 115 阅读 · 0 评论 -
Luogu P2097 资料分发1
原题传送门#include <bits/stdc++.h>using namespace std;vector<int> link[100005];//存连接线,link[t]是一个由第t个点所有连接点组成的vectorbool vis[100005];//记录是否访问过int pointNum, linkNum;void dfs(int x){ vis...原创 2019-02-17 20:02:35 · 161 阅读 · 0 评论 -
Luogu P1363 幻想迷宫
原题传送门#include <bits/stdc++.h>using namespace std;const int N = 1500 + 5;bool mp[N][N];int vis[N][N][3];//[][][0] x; [][][1] y; [][][2] vis or notint movex[] = { 0,-1,0,1 };int movey[] = ...原创 2019-02-23 09:35:20 · 89 阅读 · 0 评论 -
Luogu P1387 最大正方形
原题传送门#include <bits/stdc++.h>using namespace std;int mp[105][105];int ans[105][105];int main(){ int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j =...原创 2019-02-23 09:45:49 · 102 阅读 · 0 评论 -
Luogu P1010 幂次方
原题传送门#include <iostream>#include <cmath>using namespace std;void work(int n){ if (n == 0) { return; } int maxx = log2(n);//寻找小于n的最大的二次幂 if (maxx == 0) { cout << "2(0...原创 2019-02-18 10:26:11 · 79 阅读 · 0 评论 -
Luogu P1074 靶形数独
原题传送门#include <bits/stdc++.h>using namespace std;struct consult_row_0 {//定义结构体,把行和这一行上0的个数捆绑起来 int row, num_0;};struct consult_row_0 dic_row_0[10];//查询第几行有几个0int origin[10][10];//输入的数独...原创 2019-02-18 15:16:12 · 73 阅读 · 0 评论 -
Luogu P1004 方格取数
原题传送门#include <bits/stdc++.h>using namespace std;int mp[15][15];int f[15][15][15][15];//将走到目的地回头转化为两个人从起点开始走,f[i][j][k][l]表示两人走到(i,j)和(k,l)时的最大值int Max(int a, int b, int c, int d)//取最大值函数...原创 2019-02-28 19:04:12 · 105 阅读 · 0 评论 -
Luogu P1006 传纸条
原题传送门#include <bits/stdc++.h>const int M = 55;using namespace std;int f[M * 2][M][M];int a[M][M];int Max(int a, int b, int c, int d){ int t[4]; t[0] = a; t[1] = b; t[2] = c; t[3] =...原创 2019-02-25 15:04:45 · 70 阅读 · 0 评论 -
Luogu P1855 榨取kkksc03
原题传送门#include <bits/stdc++.h>using namespace std;struct man { int tim; int mon;};int n, M, T;man in[210];int f[210][210][210];//step,m,tint dfs(int step, int t_left, int m_left){ if...原创 2019-02-25 15:56:52 · 102 阅读 · 0 评论 -
Luogu P1216 [IOI1994][USACO1.5]数字三角形 Number Triangles
原题传送门#include <bits/stdc++.h>using namespace std;int f[1005][1005];//f[i][j]是走到i行j列时最大值int main(){ int row;//行数 cin >> row; int in; for (int i = 1; i <= row; i++) { for (...原创 2019-02-20 15:43:51 · 184 阅读 · 0 评论 -
Luogu P1236 算24点
原题传送门#include <bits/stdc++.h>using namespace std;int in[5];int calc(int operName, int x, int y){ if (operName == 1)//+ { return x + y; } if (operName == 2)//- { if (x - y <=...原创 2019-02-20 20:55:13 · 271 阅读 · 0 评论 -
Luogu P2690 接苹果
原题传送门#include <bits/stdc++.h>using namespace std;int f[1005][35];//f[时间][移动次数]=最大接到苹果数 int T,W;//总时间,最大移动次数 int app[1005];//下落地点 int dfs(int t_now,int last_pos,int move)//当前位置,上次的地点,移动次数...原创 2019-03-02 14:15:59 · 226 阅读 · 0 评论 -
Luogu P1091 合唱队形
原题传送门#include <bits/stdc++.h>using namespace std;int n;int a[105];//身高序列int head_to_tail[105];//方向从头到尾,到第i个为止,包含第i个在内,a[]的最长上升子序列(非连续)的长度int tail_to_head[105];//方向从尾到头,到第i个为止,包含第i个在内,a[]的...原创 2019-02-21 11:11:17 · 110 阅读 · 0 评论 -
Luogu P2068 统计和
原题传送门#include &lt;bits/stdc++.h&gt;using namespace std;int c[100005];int a[100005];int n;int lowbit(int x){ return x &amp; (-x);}int Sum(int i){ int res = 0; while (i &gt; 0) { res +...原创 2019-03-02 18:54:05 · 118 阅读 · 0 评论 -
Luogu 月赛 P5238 整数校验器
原题传送门#include <bits/stdc++.h>using namespace std;bool valid(string s){ if (s == "0") return true; if (s == "-")//巨坑无比 return false; if (s[0] == '-'&&s[1] == '0') return fal...原创 2019-03-02 20:23:57 · 225 阅读 · 0 评论 -
Luogu 月赛 P5239 回忆京都
原题传送门#include <bits/stdc++.h>typedef long long ll;using namespace std;const int MOD = 19260817;ll a[1005][1005];//a[down][up]ll sum[1005][1005];int main(){ ios::sync_with_stdio(false...原创 2019-03-02 21:15:57 · 173 阅读 · 0 评论 -
Luogu P1958 上学路线
原题传送门DP#include &lt;iostream&gt;int a, b;using namespace std;int map[20][20];int gap[20][20];int main(){ cin &gt;&gt; a &gt;&gt; b; int inx, iny; int t; cin &gt原创 2019-02-11 20:37:31 · 235 阅读 · 0 评论 -
Luogu P1164 小A点菜
原题传送门#include <bits/stdc++.h>using namespace std;int ans[105][10005];//ans[i][j]表示在第i道菜之前花完j元的方法数,在main外已初始化为0int price[105];//价格int main(){ int n, m; cin >> n >> m; for ...原创 2019-02-17 19:31:22 · 309 阅读 · 0 评论 -
Luogu P1434 [SHOI2002]滑雪
原题传送门#include <bits/stdc++.h>using namespace std;int x_n, y_n;int height[105][105];int dis[105][105];int movex[] = { 0,0,1,-1 };int movey[] = { -1,1,0,0 };int dfs(int x, int y){ if ...原创 2019-02-17 16:03:50 · 92 阅读 · 0 评论 -
Luogu P1002 过河卒
原题传送门#include &lt;bits/stdc++.h&gt;using namespace std;int xend,yend,xbeg,ybeg;int walk[17][17]={0};int mp[17][17]={0};int movex[]={0,-1,0,1};int movey[]={-1,0,1,0};bool flag=false;string co...原创 2019-02-09 20:10:25 · 163 阅读 · 0 评论 -
Luogu P1605 迷宫
原题传送门#include &lt;bits/stdc++.h&gt;using namespace std;int gap_pic[7][7];int walk_pic[7][7];int gap_num;int begin_x,begin_y,end_x,end_y;int x,y;int movex[]={1,-1,0,0};int movey[]={0,0,1,-1};...原创 2019-02-09 20:10:04 · 98 阅读 · 0 评论 -
Luogu P1094 纪念品分组
原题传送门#include &lt;bits/stdc++.h&gt;using namespace std;template &lt;class T&gt;void print(vector&lt;T&gt; v){ auto it=v.begin(); for(;it!=v.end();it++) cout&lt;&lt;*原创 2019-02-09 20:08:05 · 232 阅读 · 0 评论 -
Luogu P1223 排队接水
原题传送门题目描述有n个人在一个水龙头前排队接水,假如每个人接水的时间为Ti,请编程找出这n个人排队的一种顺序,使得n个人的平均等待时间最小。输入格式:输入文件共两行,第一行为n;第二行分别表示第1个人到第n个人每人的接水时间T1,T2,…,Tn,每个数据之间有1个空格。输出格式:输出文件有两行,第一行为一种排队顺序,即1到n的一种排列;第二行为这种排列方案下的平均等待时间(输出结果精...原创 2019-02-09 20:07:52 · 220 阅读 · 0 评论 -
Luogu P1208 [USACO1.3]混合牛奶 Mixing Milk
原题传送门#include &lt;bits/stdc++.h&gt;using namespace std;struct farmer{ int price,provide;};bool cmp(farmer a,farmer b)//越便宜并且供应量越大越有利,总不可能先挑贵的选{ if(a.price!=b.price) return a.price&lt;b...原创 2019-02-09 20:07:39 · 880 阅读 · 0 评论 -
Luogu P1090 合并果子
原题传送门#include &amp;lt;bits/stdc++.h&amp;gt;using namespace std;int main(){ //srand(time(0)); int n; cin&amp;gt;&amp;gt;n; //n=7; vector&amp;lt;int&amp;gt; v; for(int i=原创 2019-02-09 20:06:46 · 89 阅读 · 0 评论 -
Luogu P1282 多米诺骨牌
原题传送门#include <bits/stdc++.h>using namespace std;const int N = 1004;const int INF = 0x7f7f7f7f;int fewest_time[N][6 * N];//[i][j]=[前i个][up和为j]最少交换次数int up[N], down[N];//上下层数组int main()...原创 2019-02-21 16:14:43 · 62 阅读 · 0 评论 -
Luogu P1451 求细胞数量
原题传送门广搜版#include <bits/stdc++.h>using namespace std;char mp[105][105];int movex[]={1,-1,0,0};int movey[]={0,0,-1,1};queue< pair<int,int> > q;int cnt;int m,n;void bfs(int ...原创 2019-02-08 19:39:11 · 91 阅读 · 0 评论 -
Luogu P3367 并查集
原题传送门#include <iostream>using namespace std;int loop[10010];//查找上一级int find_root(int leaf){ if (loop[leaf] == leaf) return leaf; else return loop[leaf] = find_root...原创 2019-02-09 14:50:36 · 122 阅读 · 0 评论 -
Luogu P1443 马的遍历
原题传送门#include &lt;bits/stdc++.h&gt;using namespace std;int movex[] = { 1,1,2,2,-1,-1,-2,-2 };int movey[] = { -2,2,-1,1,2,-2,1,-1 };int x_n, y_n;int ans[405][405];bool walk[405][405];queue&lt;...原创 2019-02-16 21:54:36 · 132 阅读 · 0 评论 -
CF900B Position in Fraction
原题传送门#include &lt;bits/stdc++.h&gt;using namespace std;int main(){ int a, b, c; cin &gt;&gt; a &gt;&gt; b &gt;&gt; c; for (int i = 1; i &lt;= 300; i++) { a *= 10; if (a /原创 2019-02-16 17:46:34 · 114 阅读 · 0 评论 -
CF495B Modular Equations
原题传送门#include &lt;bits/stdc++.h&gt;using namespace std;int main(){ int a, b; cin &gt;&gt; a &gt;&gt; b; if (a == b) { cout &lt;&lt; "infinity" &lt;&a原创 2019-02-16 14:14:56 · 115 阅读 · 0 评论 -
Luogu P1141 01迷宫
原题传送门#include <bits/stdc++.h>using namespace std;char mp[1005][1005];//存图int ans[1005][1005];//存最后答案bool vis[1005][1005];//记录是否访问过int n;//边界int movex[] = { 0,0,-1,1 };//移动int movey[] = ...原创 2019-02-17 10:32:52 · 87 阅读 · 0 评论 -
Luogu P1908 逆序对
原题传送门#include <bits/stdc++.h>typedef long long ll;using namespace std;const ll N = ll(5e5 + 4);ll n;ll a[N];//输入的原数组 ll sorted[N];//排好的数组 ll ans;//总逆序对数 void mergeSort(int left, int r...原创 2019-02-22 15:34:08 · 129 阅读 · 0 评论 -
Luogu P1433 吃奶酪
原题传送门#include <bits/stdc++.h>using namespace std;double dis[20][20];//存两点间距离,dis[i][j]表示第i个点到第j个点距离double point[20][2];//存坐标bool walk[20];//记录点是否被访问过int n;//总点数double ans = 1e9;//距离最小值...原创 2019-02-17 15:05:51 · 305 阅读 · 0 评论 -
Luogu P1135 奇怪的电梯
原题传送门DFS版#include <bits/stdc++.h>using namespace std;int N;int num[205];bool vis[205];int beg, end;int minn = 0x7f7f7f7f;void dfs(int now, int step){ if (now == end) { minn = min...原创 2019-03-03 13:36:29 · 145 阅读 · 0 评论