题解
wu-kan
<https://wu-kan.cn>
展开
-
题解:2018 Multi-University Training Contest 1
垫底进队之后第一次集训。Maximum Multiple3的倍数拆1,1,1,4的倍数拆1,1,2,优先拆3的倍数。#include&amp;amp;amp;amp;amp;lt;stdio.h&amp;amp;amp;amp;amp;gt;long long t,n;int main(){ for(scanf(&amp;amp;amp;amp;quot;%lld&amp;amp;amp;amp;quot;,&原创 2018-08-14 21:20:59 · 157 阅读 · 0 评论 -
题解:ACM/ICPC 2018亚洲区预选赛北京赛站网络赛
Saving Tang Monk II按气罐数量分层建图跑最短路。#include&lt;bits/stdc++.h&gt;#define POS(i,j,k) ((k)*(n)*(m)+(i)*(m)+(j))using namespace std;typedef int ll;const int INF=1e9;struct Graph{ struct Vertex { ...原创 2018-09-23 13:30:27 · 446 阅读 · 0 评论 -
题解:The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
Live Love#include<stdio.h>int t,n,m;int main(){ for(scanf("%d",&t); t--;) { scanf("%d%d",&n,&m); if(n==1||!m)printf("%d %d\n",m,m); else for(int i=1,tmp,res; i<=m; ++i..原创 2018-09-19 10:15:21 · 427 阅读 · 0 评论 -
题解:ACM-ICPC 2018 焦作赛区网络预赛
Magic Mirror#include &amp;amp;lt;cstdio&amp;amp;gt;#include &amp;amp;lt;cstring&amp;amp;gt;int T;char s[20],a[20]=&amp;quot;JESSIE&amp;quot;,b[20]=&amp;quot;jessie&amp;quot;;bool o;原创 2018-09-19 10:44:56 · 322 阅读 · 0 评论 -
题解:Ural Regional School Programming Contest 2011
GOV Chronicles体验极差的四级阅读理解,大致是在文章里找每个人参加了多少比赛…用一下Ctrl+F。漏了最后面还有两个人各参加了一场比赛还wa了一发。有几个人的信息比较含糊所幸样例里还给了答案。#include&amp;amp;amp;lt;stdio.h&amp;amp;amp;gt;int n,a[14]= {5,21,12,2,1,4,6,1,4,4,1,0,1,1};int main(){ scanf(&amp原创 2018-10-01 18:47:57 · 295 阅读 · 0 评论 -
题解:Ural Championship 2011
Help in the RNOS#include<bits/stdc++.h>using namespace std;typedef long long ll;ll cal(char s[],int n){ char t[63]; fill(t,t+n,'0'); t[n-1]='1'; ll ans=0; for(int i=n-1; ~i; --i) if(...原创 2018-10-05 12:34:24 · 199 阅读 · 0 评论 -
题解:Ural Championship 2012
Brainwashing Device#include&lt;bits/stdc++.h&gt;using namespace std;const int N=511,INF=1e9;int n,K,f[N][N],a[N][N],c[N][N],s[N][N],g[N][N];int main(){ scanf("%d%d",&amp;n,&amp;K); for(int i原创 2018-10-06 15:46:30 · 148 阅读 · 0 评论 -
题解:2009-2010 ACM-ICPC Northeastern European Regional Contest (NEERC 09)
Business Center#include &amp;amp;lt;cstdlib&amp;amp;gt;#include &amp;amp;lt;algorithm&amp;amp;gt;using namespace std;int n,m;int main(){ while (~scanf(&amp;quot;%d%d&amp;quot;,&amp原创 2018-10-06 16:11:56 · 440 阅读 · 0 评论 -
题解:无旋Treap练习
Tyvj 1728 普通平衡树#include&amp;amp;amp;amp;amp;amp;amp;amp;lt;bits/stdc++.h&amp;amp;amp;amp;amp;amp;amp;amp;gt;using namespace std;typedef int ll;struct FhqTreap{ struct Node { int ch[2],siz; ll key,val; }; vector&a原创 2018-10-18 08:58:12 · 248 阅读 · 0 评论 -
题解:2012-2013 ACM-ICPC, Central Europe Regional Contest (CERC 12)
Kingdoms破产是收支不平衡时才有概率发生,并且一个国家破产之后有概率导致破产#include&amp;lt;bits/stdc++.h&amp;gt;using namespace std;int t,n,a[31][31],cnt[1&amp;lt;&amp;lt;20],ans;void dfs(int s){ if(cnt[s])return; for(int i=0; i&amp;l原创 2018-10-16 10:44:48 · 394 阅读 · 0 评论 -
题解:Ural Championship 2010
The House of Doctor Dee#include&lt;bits/stdc++.h&gt;#define X first#define Y secondusing namespace std;typedef long long ll;typedef pair&lt;ll,ll&gt; Coord;pair&lt;Coord,Coord&gt; v[2];int mai原创 2018-10-20 20:15:13 · 187 阅读 · 0 评论 -
题解:2017-2018 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2017)
Concerts辣鸡数据范围。滚动DP。#include<bits/stdc++.h>using namespace std;const int N=1e7+9,M=1e9+7;char a[N],b[N];int n,k,f[2][N],h[127];int main(){ scanf("%d%d",&k,&n); for(char c='A'; ...原创 2018-10-21 23:00:42 · 950 阅读 · 0 评论 -
题解:珂朵莉树练习题组
Willem, Chtholly and Seniorious#include&amp;amp;amp;amp;amp;lt;bits/stdc++.h&amp;amp;amp;amp;amp;gt;#define mul(a,b,c) ((a)*(b)%(c))using namespace std;typedef long long ll;typedef pair&amp;amp;amp;amp;amp;lt;int,ll&am原创 2018-10-22 00:52:29 · 950 阅读 · 0 评论 -
题解:[UVA-11426]GCD - Extreme (II)
GCD - Extreme (II)求∑i=1n∑j=i+1ngcd(i,j)\sum_{i=1}^n\sum_{j=i+1}^n\gcd(i,j)∑i=1n∑j=i+1ngcd(i,j)。解法一:蓝书解法,计算贡献设f(n)=∑i=1n−1gcd(i,n)f(n)=\sum_{i=1}^{n-1}\gcd(i,n)f(n)=∑i=1n−1gcd(i,n),则所求答案为f(n)f(...原创 2018-10-24 18:30:35 · 244 阅读 · 0 评论 -
题解:2015-2016 Petrozavodsk Winter Training Camp, Saratov SU Contest
Maximum Product#include<bits/stdc++.h>using namespace std;typedef long long ll;vector<ll> a,b,ans;ll n;ll product(const vector<ll> &v){ ll ret=1,i=0; while(!v[i])++i; f...原创 2018-10-30 10:29:56 · 1632 阅读 · 0 评论 -
题解:ACM-ICPC 2018 徐州赛区网络预赛
队伍人不齐打这场真心累啊…BE, GE or NE#include &amp;amp;lt;cstdio&amp;amp;gt;#include &amp;amp;lt;cstring&amp;amp;gt;#include &amp;amp;lt;algorithm&amp;amp;gt;using namespace std;const int maxn=1000+10;int原创 2018-09-10 09:06:36 · 297 阅读 · 0 评论 -
题解:2018 Multi-University Training Contest 7
Sequence#include&lt;bits/stdc++.h&gt;#define mul(a,b,c) (1LL*(a)*(b)%(c))using namespace std;typedef int ll;const ll N=3,M=1e9+7;struct Matrix{ static int n; ll a[N][N]; Matrix(ll ...原创 2018-09-12 09:23:34 · 346 阅读 · 0 评论 -
题解:单调队列/单调栈练习题组
单调栈可以找到从左/右遍历第一个比当前元素小/大的元素的位置,以及比当前元素小的元素的数量。单调队列可用于求连续区间最值。Sliding Window单调队列模板题,求n个数每k个连续的数的最小最大值;最大值可直接插相反数进去,取出的时候再取回即可。poj上STL特别的慢了,语言要选C++而非G++才能勉强跑过…大致能看个做法即可。用数组模拟STL队列直接快了一倍多…#include&...原创 2018-09-03 21:01:23 · 632 阅读 · 0 评论 -
题解:2018 Multi-University Training Contest 2
Game先手的人可以通过选1,不选1的方式操纵游戏的进程,因此有必胜策略。#include&amp;lt;stdio.h&amp;gt;int main(){ for(int n; ~scanf(&quot;%d&quot;,&amp;amp;n);)printf(&quot;Yes\n&quot;);}Swaps and Inversions一个逆序对对答案的贡原创 2018-08-18 20:09:17 · 210 阅读 · 0 评论 -
题解:2018 Multi-University Training Contest 3
Ascending Rating从后向前扫描维护当前位置开始的m个区间的LIS。 全程使用long long减少取模次数,否则会T。#include&lt;stdio.h&gt;#define N 10000009long long t,n,m,k,p,q,r,M,a[N],Q[N];int main(){ for(scanf("%lld",&amp;t); t--;)...原创 2018-08-18 20:33:07 · 177 阅读 · 0 评论 -
题解:2012 ACM-ICPC Asia Dhaka Regional Contest
Wedding of Sultan#include<stdio.h>char s[63];int t,k,kase=0,ans[99];void dfs(char u){ for(; s[++k]!=u; dfs(s[k]))++ans[s[k]],++ans[u];}int main(){ for(scanf("%d",&t); t--;)...原创 2018-08-26 20:50:22 · 268 阅读 · 0 评论 -
题解:2018 Multi-University Training Contest 4
Problem B. Harvest of Apples#include<bits/stdc++.h>#define mul(a,b,c) ((a)*(b)%(c))#define inv(a,m) pow(a,m-2,m)#define C(n,m) mul(mul(f.fac[n],f.ifac[m],M),f.ifac[(n)-(m)],M)using namespa...原创 2018-08-19 21:24:21 · 246 阅读 · 0 评论 -
题解:2018 Multi-University Training Contest 8
Character Encoding容斥一下即可。#include<bits/stdc++.h>#define mul(a,b,c) ((a)*(b)%(c))#define inv(a,b) pow(a,(b)-2,b)using namespace std;typedef long long ll;const ll N=1e5+7,M=998244353;ll ...原创 2018-08-23 00:15:13 · 269 阅读 · 0 评论 -
题解:2014 ACM-ICPC Asia Dhaka Regional Contest
Decoding Baby Boos另解:使用链表快速合并。#include&lt;bits/stdc++.h&gt;using namespace std;char s[1000009],a[9],b[9];int t,r;int main(){ for(scanf("%d",&amp;t); t--;) { vector&lt;list&l原创 2018-08-27 13:55:47 · 315 阅读 · 0 评论 -
题解:2018 Multi-University Training Contest 5
Beautiful Now以为是贪心但是贪心的策略过不了2311,于是暴搜。#include<bits/stdc++.h>using namespace std;char s[15];int t,k,mi,ma;void dfs(int n,int k,int v){ if(k<0)return; if(!s[n])mi=min(mi,v),ma...原创 2018-08-20 21:14:41 · 202 阅读 · 0 评论 -
题解:2018 Multi-University Training Contest 9
Rikka with Nash Equilibrium#include&amp;lt;stdio.h&amp;gt;#include&amp;lt;string.h&amp;gt;typedef long long ll;ll t,n,m,k,f[2][99][99];int main(){ for(scanf(&quot;%lld&quot;,&amp;amp;t); t-原创 2018-08-24 00:27:03 · 187 阅读 · 0 评论 -
题解:ACM ICPC 2013–2014, Northeastern European Regional Contest
Bonus Cards概率dp。#include&lt;bits/stdc++.h&gt;#define cin fin#define cout foutusing namespace std;ifstream fin("bonus.in");ofstream fout("bonus.out");double f[3009][3009]/*= {1}*/;//去掉注释会因为生成...原创 2018-08-28 17:25:38 · 392 阅读 · 0 评论 -
题解:2015 ACM-ICPC Asia Dhaka Regional Contest
Automatic Cheater Detection没注意到难度取值范围小于十,于是写了个二分跑过去了,还挺快的。#include&amp;lt;bits/stdc++.h&amp;gt;using namespace std;char r[9];int t,q;int main(){ for(scanf(&quot;%d&quot;,&amp;amp;t); t--;) {原创 2018-08-31 23:56:05 · 213 阅读 · 0 评论 -
题解:2018 Multi-University Training Contest 10
Problem G. Cyclic递推。#include<stdio.h>#define N 100009#define M 998244353#define mul(a,b,c) ((a)*(b)%(c))typedef long long ll;ll t,n,f[N]= {0,1,0,1,1};int main(){ for(ll i=5; i<...原创 2018-08-24 21:07:34 · 368 阅读 · 0 评论 -
题解:2018 Multi-University Training Contest 6
oval-and-rectangle#include&amp;amp;lt;stdio.h&amp;amp;gt;#include&amp;amp;lt;math.h&amp;amp;gt;int t,a,b;int main(){ for(scanf(&amp;quot;%d&amp;quot;,&amp;amp;amp;t); t--; printf(&原创 2018-08-21 22:08:36 · 191 阅读 · 0 评论 -
题解:2018中国大学生程序设计竞赛 - 网络选拔赛
怒草评测姬Buy and Resell#include&amp;amp;amp;lt;bits/stdc++.h&amp;amp;amp;gt;using namespace std;typedef long long ll;struct Node{ ll val,last; bool operator&amp;amp;amp;lt;(const Node &amp;amp;amp;amp;u)const原创 2018-08-25 20:21:47 · 1264 阅读 · 0 评论 -
题解:ACM-ICPC 2018 南京赛区网络预赛
An Olympian Math Problem#include&amp;amp;lt;stdio.h&amp;amp;gt;int main(){ long long t,n; for(scanf(&amp;quot;%lld&amp;quot;,&amp;amp;amp;t); t--; printf(&amp;quot;%lld\n&amp;quot;,n原创 2018-09-02 16:46:05 · 319 阅读 · 0 评论 -
题解:ACM-ICPC 2018 沈阳赛区网络预赛
Made In HeavenAstar求K短路。#include&lt;cstdio&gt;#include&lt;vector&gt;#include&lt;queue&gt;using namespace std;typedef int ll;const ll INF=1e9;struct Graph{ struct Vertex { ve...原创 2018-09-08 17:58:14 · 426 阅读 · 0 评论 -
题解:Dhaka 2011
Binary Matrix#include &lt;cstdio&gt;#include &lt;cstdlib&gt;#include &lt;cstring&gt;#include &lt;algorithm&gt;#include &lt;queue&gt;#define N 2010using namesp原创 2018-10-27 18:02:45 · 260 阅读 · 0 评论