2016 Problems
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+5
- 2016/finals/boomerang_crews.cppAdded+143
- 2016/finals/boomerang_crews.htmlAdded+68
- 2016/finals/boomerang_crews.inAdded+3
- 2016/finals/boomerang_crews.mdAdded+52
- 2016/finals/boomerang_crews.outAdded+75
- 2016/finals/grundy_graph.cppAdded+202
- 2016/finals/grundy_graph.htmlAdded+51
- 2016/finals/grundy_graph.inAdded+3
- 2016/finals/grundy_graph.mdAdded+48
- 2016/finals/grundy_graph.outAdded+44
- 2016/finals/maximinimax_flow.cppAdded+271
- 2016/finals/maximinimax_flow.htmlAdded+93
- 2016/finals/maximinimax_flow.inAdded+3
- 2016/finals/maximinimax_flow.mdAdded+76
- 2016/finals/maximinimax_flow.outAdded+85
- 2016/finals/rainbow_string.cppAdded+218
- 2016/finals/rainbow_string.htmlAdded+74
- 2016/finals/rainbow_string.inAdded+3
- 2016/finals/rainbow_string.mdAdded+35
- 2016/finals/rainbow_string.outAdded+55
- 2016/finals/rng.cppAdded+200
- 2016/finals/rng.htmlAdded+66
- 2016/finals/rng.inAdded+3
- 2016/finals/rng.mdAdded+66
- 2016/finals/rng.outAdded+46
- 2016/finals/snake_and_ladder.cppAdded+178
- 2016/finals/snake_and_ladder.htmlAdded+48
- 2016/finals/snake_and_ladder.inAdded
- 2016/finals/snake_and_ladder.mdAdded+67
- 2016/finals/snake_and_ladder.outAdded+529
- 2016/quals/boomerang_constellations.htmlAdded+45
- 2016/quals/boomerang_constellations.inAdded
- 2016/quals/boomerang_constellations.mdAdded+37
- 2016/quals/boomerang_constellations.outAdded+75
- 2016/quals/high_security.htmlAdded+62
- 2016/quals/high_security.inAdded
- 2016/quals/high_security.mdAdded+46
- 2016/quals/high_security.outAdded+307
- 2016/quals/price.htmlAdded+53
- 2016/quals/price.inAdded
- 2016/quals/price.mdAdded+47
- 2016/quals/price.outAdded+55
- 2016/quals/text_editor.htmlAdded+67
- 2016/quals/text_editor.inAdded
- 2016/quals/text_editor.mdAdded+54
- 2016/quals/text_editor.outAdded+305
- 2016/round1/boomerang_tournament.htmlAdded+77
- 2016/round1/boomerang_tournament.inAdded+2395
- 2016/round1/boomerang_tournament.mdAdded+62
62 unmodified lines636465666768697062 unmodified lines2015/finals/fox_hawks.in filter=lfs diff=lfs merge=lfs -text2015/round1/autocomplete.in filter=lfs diff=lfs merge=lfs -text2015/round1/corporate_gifting.in filter=lfs diff=lfs merge=lfs -text2016/finals/boomerang_crews.in filter=lfs diff=lfs merge=lfs -text2016/finals/grundy_graph.in filter=lfs diff=lfs merge=lfs -text2016/finals/maximinimax_flow.in filter=lfs diff=lfs merge=lfs -text2016/finals/rainbow_string.in filter=lfs diff=lfs merge=lfs -text2016/finals/rng.in filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143// BOOMERANG CREWS
// Official Solution by Jacob Plachta
#define DEBUG 0
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
using namespace std;
#define LL long long
#define LD long double
#define PR pair<int,int>
#define Fox(i,n) for (i=0; i<n; i++)
#define Fox1(i,n) for (i=1; i<=n; i++)
#define FoxI(i,a,b) for (i=a; i<=b; i++)
#define FoxR(i,n) for (i=(n)-1; i>=0; i--)
#define FoxR1(i,n) for (i=n; i>0; i--)
#define FoxRI(i,a,b) for (i=b; i>=a; i--)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define Sz(s) int((s).size())
#define All(s) (s).begin(),(s).end()
#define Fill(s,v) memset(s,v,sizeof(s))
#define pb push_back
#define mp make_pair
#define x first
#define y second
template<typename T> T Abs(T x) { return(x<0 ? -x : x); }
template<typename T> T Sqr(T x) { return(x*x); }
string plural(string s) { return(Sz(s) && s[Sz(s)-1]=='x' ? s+"en" : s+"s"); }
const int INF = (int)1e9;
const LD EPS = 1e-9;
const LD PI = acos(-1.0);
//#if DEBUG
#define GETCHAR getchar
/*#else
#define GETCHAR getchar_unlocked
#endif*/
bool Read(int &x)
{
char c,r=0,n=0;
x=0;
for(;;)
{
c=GETCHAR();
if ((c<0) && (!r))
return(0);
if ((c=='-') && (!r))
n=1;
else
if ((c>='0') && (c<='9'))
x=x*10+c-'0',r=1;
else
if (r)
break;
}
if (n)
x=-x;
return(1);
}
int main()
{
if (DEBUG)
freopen("in.txt","r",stdin);
int T,t;
int N,M,D;
int i,j,c,free;
int r1,r2,m;
static int A[100000],B[100000];
set<PR> S;
set<PR>::iterator I;
Read(T);
Fox1(t,T)
{
Read(N),Read(M),Read(D);
Fox(i,N)
Read(A[i]);
Fox(i,M)
Read(B[i]);
sort(A,A+N);
reverse(A,A+N);
j=free=0;
Fox(i,M)
if (B[i]<=A[0])
free++;
else
B[j++]=B[i];
M=j;
sort(B,B+M);
r1=0,r2=min(N,M);
while (r2>r1)
{
m=(r1+r2+1)>>1;
S.clear();
Fox(i,m)
S.insert(mp(A[i]%D,i));
c=1;
Fox(i,m)
{
I=S.lower_bound(mp(B[i]%D,-1));
if (I==S.end())
I=S.begin();
j=A[I->y],S.erase(I);
c+=(B[i]-j+D-1)/D-1;
if (c>N-m)
goto Bad;
}
r1=m;
continue;
Bad:;
r2=m-1;
}
printf("Case #%d: %d\n",t,free+r1);
}
return(0);
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768<p>It's time to settle things once and for all. Your boomerang crew has decided to challenge their rivals to a boomerang crew battle!</p>
<p>Your crew has <strong>N</strong> members with strengths <strong>A<sub>1..N</sub></strong>, while the opposing crew has <strong>M</strong> members with strengths <strong>B<sub>1..M</sub></strong>. The crew battle will proceed as follows:</p>
<ol><li> Each crew will arrange its members in a line, in some order. </li><li> A throwing contest will take place between the first person in your line, and the first person in your opponents' line. </li><li> Whoever loses the contest (see below for details) will leave their line permanently, while the winner will stay at the front of their line. </li><li> If one of the lines has become empty, that crew loses and the crew battle concludes. </li><li> Otherwise, back to step 2. </li></ol>
<p>However, you're not about to play fair with your enemies — you've got the following 3 things going for you:</p>
<ol><li> You will decide the initial ordering of members for <em>both</em> crews (in step 1 of the crew battle).<li> When a member of your crew with strength <strong>S</strong> competes in a throwing contest, they'll throw their boomerang a distance of <strong>S</strong> feet. On the other hand, due to a bit of subtle poisoning you've done in advance, your enemies will get tired after each throw. In particular, when a member of the rival crew with strength <strong>S</strong> competes in a throwing contest, such that they've already competed in (and won) <strong>C</strong> throwing contests previously, they'll throw their boomerang a distance of max{<strong>S</strong> - <strong>C</strong>*<strong>D</strong>, 1} feet (where <strong>D</strong> is a set constant).<li> In each throwing contest, your crew's member will win if their throw distance is greater than <em>or equal</em> to their opponent's.</ol>
<p>Despite these advantages, it's possible that you'll still be unable to emerge victorious. However, whether or not you do, you'd like to maximize the number of throwing contests that members of your crew win over the course of the crew battle (given that you choose optimal initial orderings for both lines).</p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of battles.For each battle, there are three lines.The first line contains the space-separated integers <strong>N</strong>, <strong>M</strong>, and <strong>D</strong>. The second line contains the <strong>N</strong> space-separated integers <strong>A<sub>1</sub></strong> to <strong>A<sub>N</sub></strong>.The third line contains the <strong>M</strong> space-separated integers <strong>B<sub>1</sub></strong> to <strong>B<sub>M</sub></strong>.</p>
<h3>Output</h3><p>For the <strong>i</strong>th battle, print a line containing "Case #<strong>i</strong>: " followed by the maximum number of throwing contests that your crew can win.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 75 <br />1 ≤ <strong>N</strong>, <strong>M</strong> ≤ 100,000 <br />1 ≤ <strong>A<sub>i</sub></strong>, <strong>B<sub>i</sub></strong>, <strong>D</strong> ≤ 1,000,000,000 <br /></p>
<h3>Explanation of Sample</h3><p>In the first battle, your single member cannot beat theirs. In the second battle, they can (just barely).
In the fourth battle, one solution is to arrange their crew as [35, 25, 5] and your crew as [10, 20, 30] to emerge victorious (in which case, 5 throwing contests will occur, of which your crew will win the last three).</p>123version https://git-lfs.github.com/spec/v1oid sha256:4061ff66fb665a646e9f24c016d6fc6452c217088d9787cd0b2c8654365af587size 2037385412345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152It's time to settle things once and for all. Your boomerang crew has decidedto challenge their rivals to a boomerang crew battle!
Your crew has **N** members with strengths **A1..N**, while the opposing crewhas **M** members with strengths **B1..M**. The crew battle will proceed asfollows:
1. Each crew will arrange its members in a line, in some order. 2. A throwing contest will take place between the first person in your line, and the first person in your opponents' line. 3. Whoever loses the contest (see below for details) will leave their line permanently, while the winner will stay at the front of their line. 4. If one of the lines has become empty, that crew loses and the crew battle concludes. 5. Otherwise, back to step 2.
However, you're not about to play fair with your enemies — you've got thefollowing 3 things going for you:
1. You will decide the initial ordering of members for _both_ crews (in step 1 of the crew battle). 2. When a member of your crew with strength **S** competes in a throwing contest, they'll throw their boomerang a distance of **S** feet. On the other hand, due to a bit of subtle poisoning you've done in advance, your enemies will get tired after each throw. In particular, when a member of the rival crew with strength **S** competes in a throwing contest, such that they've already competed in (and won) **C** throwing contests previously, they'll throw their boomerang a distance of max{**S** \- **C*****D**, 1} feet (where **D** is a set constant). 3. In each throwing contest, your crew's member will win if their throw distance is greater than _or equal_ to their opponent's.
Despite these advantages, it's possible that you'll still be unable to emergevictorious. However, whether or not you do, you'd like to maximize the numberof throwing contests that members of your crew win over the course of the crewbattle (given that you choose optimal initial orderings for both lines).
### Input
Input begins with an integer **T**, the number of battles. For each battle,there are three lines. The first line contains the space-separated integers**N**, **M**, and **D**. The second line contains the **N** space-separatedintegers **A1** to **AN**. The third line contains the **M** space-separatedintegers **B1** to **BM**.
### Output
For the **i**th battle, print a line containing "Case #**i**: " followed bythe maximum number of throwing contests that your crew can win.
### Constraints
1 ≤ **T** ≤ 75 1 ≤ **N**, **M** ≤ 100,000 1 ≤ **Ai**, **Bi**, **D** ≤ 1,000,000,000
### Explanation of Sample
In the first battle, your single member cannot beat theirs. In the secondbattle, they can (just barely). In the fourth battle, one solution is toarrange their crew as [35, 25, 5] and your crew as [10, 20, 30] to emergevictorious (in which case, 5 throwing contests will occur, of which your crewwill win the last three).
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475Case #1: 0Case #2: 1Case #3: 4Case #4: 3Case #5: 2Case #6: 8328Case #7: 9173Case #8: 6951Case #9: 13491Case #10: 7430Case #11: 9642Case #12: 12413Case #13: 6663Case #14: 9234Case #15: 12106Case #16: 122Case #17: 62Case #18: 162Case #19: 70Case #20: 21Case #21: 123Case #22: 134Case #23: 32Case #24: 50Case #25: 125Case #26: 20Case #27: 30Case #28: 68Case #29: 53Case #30: 11Case #31: 7Case #32: 33Case #33: 119Case #34: 64Case #35: 23Case #36: 82Case #37: 51Case #38: 24Case #39: 25Case #40: 80Case #41: 9Case #42: 107Case #43: 13Case #44: 57Case #45: 146Case #46: 39Case #47: 37Case #48: 71Case #49: 69Case #50: 51Case #51: 10Case #52: 48Case #53: 24Case #54: 36Case #55: 170Case #56: 24Case #57: 140Case #58: 25Case #59: 84Case #60: 13Case #61: 50Case #62: 83Case #63: 12Case #64: 114Case #65: 64Case #66: 43Case #67: 102Case #68: 21Case #69: 70Case #70: 3Case #71: 20Case #72: 23Case #73: 31Case #74: 67Case #75: 33123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202// GRUNDY GRAPH
// Official Solution by Jacob Plachta
#define DEBUG 0
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
using namespace std;
#define LL long long
#define LD long double
#define PR pair<int,int>
#define Fox(i,n) for (i=0; i<n; i++)
#define Fox1(i,n) for (i=1; i<=n; i++)
#define FoxI(i,a,b) for (i=a; i<=b; i++)
#define FoxR(i,n) for (i=(n)-1; i>=0; i--)
#define FoxR1(i,n) for (i=n; i>0; i--)
#define FoxRI(i,a,b) for (i=b; i>=a; i--)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define Sz(s) int((s).size())
#define All(s) (s).begin(),(s).end()
#define Fill(s,v) memset(s,v,sizeof(s))
#define pb push_back
#define mp make_pair
#define x first
#define y second
template<typename T> T Abs(T x) { return(x<0 ? -x : x); }
template<typename T> T Sqr(T x) { return(x*x); }
string plural(string s) { return(Sz(s) && s[Sz(s)-1]=='x' ? s+"en" : s+"s"); }
const int INF = (int)1e9;
const LD EPS = 1e-9;
const LD PI = acos(-1.0);
//#if DEBUG
#define GETCHAR getchar
/*#else
#define GETCHAR getchar_unlocked
#endif*/
bool Read(int &x)
{
char c,r=0,n=0;
x=0;
for(;;)
{
c=GETCHAR();
if ((c<0) && (!r))
return(0);
if ((c=='-') && (!r))
n=1;
else
if ((c>='0') && (c<='9'))
x=x*10+c-'0',r=1;
else
if (r)
break;
}
if (n)
x=-x;
return(1);
}
#define LIM 2000002
struct edge{int e, nxt;};
int V, E;
edge e[LIM], er[LIM];
int sp[LIM], spr[LIM];
int group_cnt, comp[LIM];
bool v[LIM];
int stk[LIM];
void fill_forward(int x)
{
int i;
v[x]=true;
for(i=sp[x];i;i=e[i].nxt) if(!v[e[i].e]) fill_forward(e[i].e);
stk[++stk[0]]=x;
}
void fill_backward(int x)
{
int i;
v[x]=false;
comp[x]=group_cnt;
for(i=spr[x];i;i=er[i].nxt) if(v[er[i].e]) fill_backward(er[i].e);
}
void add_edge(int v1, int v2) //add edge v1->v2
{
e [++E].e=v2; e [E].nxt=sp [v1]; sp [v1]=E;
er[ E].e=v1; er[E].nxt=spr[v2]; spr[v2]=E;
}
void SCC()
{
int i;
stk[0]=0;
memset(v, false, sizeof(v));
for(i=1;i<=V;i++) if(!v[i]) fill_forward(i);
group_cnt=0;
for(i=stk[0];i>=1;i--) if(v[stk[i]]){group_cnt++; fill_backward(stk[i]);}
}
int val[LIM];
bool visA[LIM],visB[LIM];
vector<int> con[LIM];
bool rec(int s,int i)
{
if ((i!=s) && ((i-1)/2%2))
return(1);
if (visB[i])
return(0);
visB[i]=1;
int j;
Fox(j,Sz(con[i]))
if (rec(s,con[i][j]))
return(1);
return(0);
}
int main()
{
if (DEBUG)
freopen("in.txt","r",stdin);
int T,t;
int N,M;
int i,j,a,b;
Read(T);
Fox1(t,T)
{
printf("Case #%d: ",t);
Read(N),Read(M);
N<<=1;
Fox1(i,N)
con[i].clear();
V=N;
E=0;
Fill(sp,0);
Fill(spr,0);
while (M--)
{
Read(i),Read(j);
con[i].pb(j);
add_edge(i,j);
if (j%2)
j++;
else
j--;
if (i%2)
i++;
else
i--;
con[j].pb(i);
add_edge(j,i);
}
SCC();
Fill(visA,0);
Fill(visB,0);
Fox1(i,N)
{
//Alice
a=comp[i],b=comp[i+1];
if (a==b)
goto Bad;
visA[a]=visA[b]=1;
i+=2;
//Bob
a=comp[i],b=comp[i+1];
if ((visA[a]) || (visA[b]) || (rec(i,i)) || (rec(i+1,i+1)))
goto Bad;
i++;
}
printf("Alice\n");
continue;
Bad:;
printf("Bob\n");
}
return(0);
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051<p>Alice and Bob are spending the day in the local library, learning about 2-player zero-sum games. One of the books they're reading, "Grundy Numbers For Fun And Profit" by Nim Nimberly, has an interactive insert with a bunch of graphs and instructions for a game where the players take turns colouring each graph's vertices.</p>
<p>Each game starts with a directed graph that has 2*<strong>N</strong> vertices, numbered from 1 to 2*<strong>N</strong>, all of which are initially uncoloured, and <strong>M</strong> edges. The <strong>i</strong>th edge goes from vertex <strong>A<sub>i</sub></strong> to vertex <strong>B<sub>i</sub></strong>. No two edges connect the same pair of verticesin the same direction, and no edge connects a vertex to itself.</p>
<p>Alice goes first and colours vertices 1 and 2. She must colour one of these two vertices black, and the other one white. Bob then takes his turn and similarly colours vertices 3 and 4, one of them black and the other one white. This continues with Alice colouring vertices 5 and 6, Bob colouring 7 and 8, and so on until every vertex is coloured.At the end of the game, Alice wins if there are no edges going from a black vertex to a white one. Bob wins if such an edge exists.</p>
<p>Who will win if Alice and Bob play optimally?</p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of graphs.For each graph, there is first a line containing the space-separated integers <strong>N</strong> and <strong>M</strong>. Then <strong>M</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers<strong>A<sub>i</sub></strong> and <strong>B<sub>i</sub></strong> .</p>
<h3>Output</h3><p>For the <strong>i</strong>th graph, print a line containing "Case #<strong>i</strong>: " followed by the winner of the game, either "Alice" or "Bob".</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 45 <br />1 ≤ <strong>N</strong> ≤ 500,000 <br />0 ≤ <strong>M</strong> ≤ 500,000 <br />1 ≤ <strong>A<sub>i</sub></strong>, <strong>B<sub>i</sub></strong>, ≤ 2*<strong>N</strong> <br /></p>
<h3>Explanation of Sample</h3><p>For the first graph, Alice can color vertex 1 white and vertex 2 black. Since all edges start at vertex 1, Alice will win.
For the second graph, Alice can't control the color of vertex 3. If Bob makes it white, then one of the two edges must be from a black vertex to a white vertex, so Bob wins.</p>123version https://git-lfs.github.com/spec/v1oid sha256:68b9b22aca60b72930b9484a7d427f37da5223dc1945ecbdda29adad8d789db8size 62276868123456789101112131415161718192021222324252627282930313233343536373839404142434445464748Alice and Bob are spending the day in the local library, learning about2-player zero-sum games. One of the books they're reading, "Grundy Numbers ForFun And Profit" by Nim Nimberly, has an interactive insert with a bunch ofgraphs and instructions for a game where the players take turns colouring eachgraph's vertices.
Each game starts with a directed graph that has 2***N** vertices, numberedfrom 1 to 2***N**, all of which are initially uncoloured, and **M** edges. The**i**th edge goes from vertex **Ai** to vertex **Bi**. No two edges connectthe same pair of vertices in the same direction, and no edge connects a vertexto itself.
Alice goes first and colours vertices 1 and 2. She must colour one of thesetwo vertices black, and the other one white. Bob then takes his turn andsimilarly colours vertices 3 and 4, one of them black and the other one white.This continues with Alice colouring vertices 5 and 6, Bob colouring 7 and 8,and so on until every vertex is coloured. At the end of the game, Alice winsif there are no edges going from a black vertex to a white one. Bob wins ifsuch an edge exists.
Who will win if Alice and Bob play optimally?
### Input
Input begins with an integer **T**, the number of graphs. For each graph,there is first a line containing the space-separated integers **N** and **M**.Then **M** lines follow, the **i**th of which contains the space-separatedintegers **Ai** and **Bi** .
### Output
For the **i**th graph, print a line containing "Case #**i**: " followed by thewinner of the game, either "Alice" or "Bob".
### Constraints
1 ≤ **T** ≤ 45 1 ≤ **N** ≤ 500,000 0 ≤ **M** ≤ 500,000 1 ≤ **Ai**, **Bi**, ≤ 2***N**
### Explanation of Sample
For the first graph, Alice can color vertex 1 white and vertex 2 black. Sinceall edges start at vertex 1, Alice will win. For the second graph, Alice can'tcontrol the color of vertex 3. If Bob makes it white, then one of the twoedges must be from a black vertex to a white vertex, so Bob wins.
1234567891011121314151617181920212223242526272829303132333435363738394041424344Case #1: AliceCase #2: BobCase #3: BobCase #4: AliceCase #5: AliceCase #6: BobCase #7: BobCase #8: AliceCase #9: AliceCase #10: AliceCase #11: AliceCase #12: BobCase #13: BobCase #14: BobCase #15: BobCase #16: AliceCase #17: AliceCase #18: AliceCase #19: AliceCase #20: AliceCase #21: BobCase #22: BobCase #23: BobCase #24: BobCase #25: BobCase #26: AliceCase #27: AliceCase #28: AliceCase #29: AliceCase #30: AliceCase #31: BobCase #32: BobCase #33: BobCase #34: BobCase #35: BobCase #36: BobCase #37: BobCase #38: BobCase #39: BobCase #40: BobCase #41: BobCase #42: BobCase #43: BobCase #44: Bob123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271// MAXIMINIMAX FLOW
// Official Solution by Jacob Plachta
#define DEBUG 0
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
using namespace std;
#define LL long long
#define LD long double
#define PR pair<int,int>
#define Fox(i,n) for (i=0; i<n; i++)
#define Fox1(i,n) for (i=1; i<=n; i++)
#define FoxI(i,a,b) for (i=a; i<=b; i++)
#define FoxR(i,n) for (i=(n)-1; i>=0; i--)
#define FoxR1(i,n) for (i=n; i>0; i--)
#define FoxRI(i,a,b) for (i=b; i>=a; i--)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define Sz(s) int((s).size())
#define All(s) (s).begin(),(s).end()
#define Fill(s,v) memset(s,v,sizeof(s))
#define pb push_back
#define mp make_pair
#define x first
#define y second
template<typename T> T Abs(T x) { return(x<0 ? -x : x); }
template<typename T> T Sqr(T x) { return(x*x); }
string plural(string s) { return(Sz(s) && s[Sz(s)-1]=='x' ? s+"en" : s+"s"); }
const int INF = (int)1e9;
const LD EPS = 1e-9;
const LD PI = acos(-1.0);
//#if DEBUG
#define GETCHAR getchar
/*#else
#define GETCHAR getchar_unlocked
#endif*/
bool Read(int &x)
{
char c,r=0,n=0;
x=0;
for(;;)
{
c=GETCHAR();
if ((c<0) && (!r))
return(0);
if ((c=='-') && (!r))
n=1;
else
if ((c>='0') && (c<='9'))
x=x*10+c-'0',r=1;
else
if (r)
break;
}
if (n)
x=-x;
return(1);
}
bool ReadLL(LL &x)
{
char c,r=0,n=0;
x=0;
for(;;)
{
c=GETCHAR();
if ((c<0) && (!r))
return(0);
if ((c=='-') && (!r))
n=1;
else
if ((c>='0') && (c<='9'))
x=x*10+c-'0',r=1;
else
if (r)
break;
}
if (n)
x=-x;
return(1);
}
#define LIM 500005
#define LIM2 1000000
LL BLT[2][2][LIM2+1];
void Update(int a,int b,int i,int v)
{
for (; i<=LIM2; i+=(i&-i))
BLT[a][b][i]+=v;
}
void Update2(int a,int i,int v)
{
Update(a,0,i,v);
Update(a,1,i,i*v);
}
LL Query(int a,int b,LL ii)
{
int i=(int)min(ii,(LL)LIM2);
LL v=0;
for(; i>0; i-=(i&-i))
v+=BLT[a][b][i];
return(v);
}
int main()
{
if (DEBUG)
freopen("in.txt","r",stdin);
//vars
int T,t;
int N,M;
int i,j,k;
LL r1,r2,m,m2;
LL tot,rem,cnt,sum;
LL ans;
static vector<PR> con[LIM];
static int C[LIM],dep[LIM],cyc[LIM];
static PR par[LIM];
queue<int> Q;
set<PR> S;
set<PR>::iterator I;
//testcase loop
Read(T);
Fox1(t,T)
{
//input
Read(N),Read(M);
Fox(i,N)
{
Read(j),Read(k),Read(C[i]);
j--,k--;
con[j].pb(mp(k,i));
con[k].pb(mp(j,i));
}
//BFS to find the single cycle
Fill(dep,-1);
Q.push(0),dep[0]=0;
for(;;)
{
i=Q.front(),Q.pop();
Fox(j,Sz(con[i]))
if ((k=con[i][j].x)!=par[i].x)
if (dep[k]>=0)
goto Done;
else
Q.push(k),dep[k]=dep[i]+1,par[k]=mp(i,con[i][j].y);
}
//retrace all edges in the cycle
Done:;
Fill(cyc,0);
cyc[con[i][j].y]=1;
while (i!=k)
if (dep[i]>dep[k])
{
cyc[par[i].y]=1;
i=par[i].x;
}
else
{
cyc[par[k].y]=1;
k=par[k].x;
}
//init BLTs
Fox(i,N)
{
Update2(cyc[i],C[i],1);
if (cyc[i])
S.insert(mp(C[i],i));
}
//handle operations
ans=0;
while (M--)
{
Read(i);
if (i==1)
{
//delete and re-add the adge
Read(i),i--;
Update2(cyc[i],C[i],-1);
if (cyc[i])
S.erase(mp(C[i],i));
Read(C[i]);
Update2(cyc[i],C[i],1);
if (cyc[i])
S.insert(mp(C[i],i));
}
else
{
//binary search on the answer
ReadLL(tot);
r1=1,r2=(LL)1e13;
while (r2>r1)
{
m=(r1+r2+1)>>1;
rem=tot;
//non-cycle edges
cnt=Query(0,0,m);
sum=Query(0,1,m);
rem-=cnt*m - sum;
if (rem<0)
goto Bad;
//cycle edges
I=S.begin(),i=I->x;
I++,j=I->x;
if (m<=(j<<1))
rem-=max(0LL,m - (i+j));
else
{
m2=(m+1)>>1;
cnt=Query(1,0,m2);
sum=Query(1,1,m2);
rem-=cnt*m2 - sum;
if (m&1)
rem++;
}
if (rem<0)
{
Bad:;
r2=m-1;
continue;
}
r1=m;
}
ans+=r1;
}
}
//output
printf("Case #%d: ",t);
cout << ans << endl;
//reset
Fox(i,N)
con[i].clear();
while (!Q.empty())
Q.pop();
S.clear();
Fill(BLT,0);
}
return(0);
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293<p>You're given an undirected, connected graph with <strong>N</strong> nodes (numbered from 1 to <strong>N</strong>) and <strong>N</strong> edges. The <strong>i</strong>th edge connects distinct nodes <strong>A<sub>i</sub></strong> and <strong>B<sub>i</sub></strong>, and has a capacity of <strong>C<sub>i</sub></strong>. No two edges directly connect the same pair of nodes.</p>
<p><strong>M</strong> operations will be performed on this graph, one after another. The nature of the <strong>i</strong>th operation is described by the value of <strong>O<sub>i</sub></strong>:
<p>- If <strong>O<sub>i</sub></strong> = 1, then the <strong>i</strong>th operation is an update, in which the capacity of the <strong>X<sub>i</sub></strong>th edge is changed to be <strong>Y<sub>i</sub></strong>.</p>
<p>- Otherwise, if <strong>O<sub>i</sub></strong> = 2, then the <strong>i</strong>th operation is a query, in which you must determine the maximinimax flow in the graph after <strong>Z<sub>i</sub></strong> edge augmentations.</p>
<p>What do any of those terms mean? Let's define them:</p>
<p>- An edge augmentation is a temporary increase of a certain edge's capacity by 1 for the current query.</p>
<p>- The max flow from node <strong>u</strong> to a different node <strong>v</strong> is the usual definition of maximum flow in computer science (hopefully you're familiar with it!), with node <strong>u</strong> being the source and node <strong>v</strong> being the sink. Each edge may transport flow in either direction, so it may be thought of as two directed edges (one in each direction), both with the same capacity.</p>
<p>- The minimax flow in the graph is the smallest max flow value across all pairs of distinct nodes. In other words, min{1 ≤ <strong>u</strong>, <strong>v</strong> ≤ <strong>N</strong>, <strong>u</strong> ≠ <strong>v</strong>} (F(<strong>u</strong>, <strong>v</strong>)), where F(<strong>u</strong>, <strong>v</strong>) is the max flow from node <strong>u</strong> to node <strong>v</strong>.</p>
<p>- The maximinimax flow in the graph after <strong>x</strong> edge augmentations is the largest possible minimax flow which the graph can have after <strong>x</strong> optimal edge augmentations are applied. Note that each edge can be augmented any non-negative number of times (as long as the total number of augmentations in the graph is <strong>x</strong>), and that the chosen edge augmentations are temporary — they do not change the graph for future operations.</p>
<p>To reduce the size of the output, you should simply output one integer, the sum of the answers to all of the queries.</p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of graphs.For each graph, there is a first a line containing the space-separated integers <strong>N</strong> and <strong>M</strong>.
Then, <strong>N</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers<strong>A<sub>i</sub></strong>, <strong>B<sub>i</sub></strong>, and <strong>C<sub>i</sub></strong>.
Then, <strong>M</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers<strong>O<sub>i</sub></strong>, <strong>X<sub>i</sub></strong>, and <strong>Y<sub>i</sub></strong> (if <strong>O<sub>i</sub></strong> = 1) or<strong>O<sub>i</sub></strong> and <strong>Z<sub>i</sub></strong> (if <strong>O<sub>i</sub></strong> = 2).</p>
<h3>Output</h3><p>For the <strong>i</strong>th graph, print a line containing "Case #<strong>i</strong>: " followed by the sum of the answers to all queries on that graph.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 85 <br />3 ≤ <strong>N</strong> ≤ 500,000 <br />1 ≤ <strong>M</strong> ≤ 500,000 <br />1 ≤ <strong>A<sub>i</sub></strong>, <strong>B<sub>i</sub></strong>, <strong>X<sub>i</sub></strong> ≤ <strong>N</strong> <br />1 ≤ <strong>C<sub>i</sub></strong>, <strong>Y<sub>i</sub></strong> ≤ 1,000,000 <br />0 ≤ <strong>Z<sub>i</sub></strong> ≤ 1,000,000,000,000 <br />1 ≤ <strong>O<sub>i</sub></strong> ≤ 2 <br /></p>
<h3>Explanation of Sample</h3><p>In the first graph, the max flow between any two nodes is 10, so the minimax flow is also 10. If we do no edge augmentations, then the maximinimax flow is still 10.
In the second graph, the maximinimax flow is initially 3, but is then increased to 5 before the second query for a total of 8.
In the third graph, the maximinimax flow is initially 7 (between node 2 and any other node). If we augment the edge from node 3 to node 2 twice, then the max flow between node 2 and any other node is now 9. The max flow between any other pair of nodes was already greater than 9, so the minimax flow is now 9.We can't do any better than that, so the maximinimax flow is also 9.</p>
123version https://git-lfs.github.com/spec/v1oid sha256:e7a96ad5e48bc1333e92a1e16c7c72e3149dafd769c8526295fb48114c6e0e33size 6892203212345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576You're given an undirected, connected graph with **N** nodes (numbered from 1to **N**) and **N** edges. The **i**th edge connects distinct nodes **Ai** and**Bi**, and has a capacity of **Ci**. No two edges directly connect the samepair of nodes.
**M** operations will be performed on this graph, one after another. The nature of the **i**th operation is described by the value of **Oi**:
\- If **Oi** = 1, then the **i**th operation is an update, in which thecapacity of the **Xi**th edge is changed to be **Yi**.
\- Otherwise, if **Oi** = 2, then the **i**th operation is a query, in whichyou must determine the maximinimax flow in the graph after **Zi** edgeaugmentations.
What do any of those terms mean? Let's define them:
\- An edge augmentation is a temporary increase of a certain edge's capacityby 1 for the current query.
\- The max flow from node **u** to a different node **v** is the usualdefinition of maximum flow in computer science (hopefully you're familiar withit!), with node **u** being the source and node **v** being the sink. Eachedge may transport flow in either direction, so it may be thought of as twodirected edges (one in each direction), both with the same capacity.
\- The minimax flow in the graph is the smallest max flow value across allpairs of distinct nodes. In other words, min{1 ≤ **u**, **v** ≤ **N**, **u** ≠**v**} (F(**u**, **v**)), where F(**u**, **v**) is the max flow from node**u** to node **v**.
\- The maximinimax flow in the graph after **x** edge augmentations is thelargest possible minimax flow which the graph can have after **x** optimaledge augmentations are applied. Note that each edge can be augmented any non-negative number of times (as long as the total number of augmentations in thegraph is **x**), and that the chosen edge augmentations are temporary — theydo not change the graph for future operations.
To reduce the size of the output, you should simply output one integer, thesum of the answers to all of the queries.
### Input
Input begins with an integer **T**, the number of graphs. For each graph,there is a first a line containing the space-separated integers **N** and**M**. Then, **N** lines follow, the **i**th of which contains the space-separated integers **Ai**, **Bi**, and **Ci**. Then, **M** lines follow, the**i**th of which contains the space-separated integers **Oi**, **Xi**, and**Yi** (if **Oi** = 1) or **Oi** and **Zi** (if **Oi** = 2).
### Output
For the **i**th graph, print a line containing "Case #**i**: " followed by thesum of the answers to all queries on that graph.
### Constraints
1 ≤ **T** ≤ 85 3 ≤ **N** ≤ 500,000 1 ≤ **M** ≤ 500,000 1 ≤ **Ai**, **Bi**, **Xi** ≤ **N** 1 ≤ **Ci**, **Yi** ≤ 1,000,000 0 ≤ **Zi** ≤ 1,000,000,000,000 1 ≤ **Oi** ≤ 2
### Explanation of Sample
In the first graph, the max flow between any two nodes is 10, so the minimaxflow is also 10. If we do no edge augmentations, then the maximinimax flow isstill 10. In the second graph, the maximinimax flow is initially 3, but isthen increased to 5 before the second query for a total of 8. In the thirdgraph, the maximinimax flow is initially 7 (between node 2 and any othernode). If we augment the edge from node 3 to node 2 twice, then the max flowbetween node 2 and any other node is now 9. The max flow between any otherpair of nodes was already greater than 9, so the minimax flow is now 9. Wecan't do any better than that, so the maximinimax flow is also 9.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485Case #1: 10Case #2: 8Case #3: 9Case #4: 11Case #5: 123Case #6: 304383647899Case #7: 144112755379Case #8: 144348500415Case #9: 301317029285Case #10: 89000851465Case #11: 184211069719Case #12: 176567033514Case #13: 153326177885Case #14: 104125067299Case #15: 246704568156Case #16: 163533028903Case #17: 175697219713Case #18: 114075799814Case #19: 3009664900678Case #20: 123353189950Case #21: 45047940360Case #22: 142130723516Case #23: 57958395290Case #24: 3762906937963Case #25: 99917051550Case #26: 887652200701Case #27: 199408849379Case #28: 104532232592Case #29: 281496624236Case #30: 139464844782Case #31: 173120052623Case #32: 158041982161Case #33: 475569676769Case #34: 381550956008Case #35: 4770638614Case #36: 1240432768678Case #37: 329171997615Case #38: 2462187018107Case #39: 245022020493Case #40: 478905356695Case #41: 351947046120Case #42: 276673766339Case #43: 109500766093Case #44: 330374064692Case #45: 337624423704Case #46: 86946443291Case #47: 1200181393491Case #48: 184194396421Case #49: 43690762833Case #50: 127163551554Case #51: 111218335988Case #52: 122580945994Case #53: 586334704876Case #54: 293149094452Case #55: 22761536987Case #56: 78073808557Case #57: 111237890055Case #58: 288178586400Case #59: 75200460726Case #60: 271371672830Case #61: 46692093752Case #62: 44097908017Case #63: 383069096330Case #64: 380975476663Case #65: 396083749712Case #66: 368623446537Case #67: 152404797320Case #68: 1746064129Case #69: 134261898464Case #70: 184122274881Case #71: 708871243263Case #72: 134687150646Case #73: 1869622095930Case #74: 92316044411Case #75: 407277939444Case #76: 694274474852Case #77: 23876452440Case #78: 6962558256345Case #79: 107715896989Case #80: 1248316489406Case #81: 225590525246Case #82: 77022047743Case #83: 392171117277Case #84: 213573472156Case #85: 1997303127123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218// RAINBOW STRING
// Official Solution by Jacob Plachta
#define DEBUG 0
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
using namespace std;
#define LL long long
#define LD long double
#define PR pair<int,int>
#define Fox(i,n) for (i=0; i<n; i++)
#define Fox1(i,n) for (i=1; i<=n; i++)
#define FoxI(i,a,b) for (i=a; i<=b; i++)
#define FoxR(i,n) for (i=(n)-1; i>=0; i--)
#define FoxR1(i,n) for (i=n; i>0; i--)
#define FoxRI(i,a,b) for (i=b; i>=a; i--)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define Sz(s) int((s).size())
#define All(s) (s).begin(),(s).end()
#define Fill(s,v) memset(s,v,sizeof(s))
#define pb push_back
#define mp make_pair
#define x first
#define y second
template<typename T> T Abs(T x) { return(x<0 ? -x : x); }
template<typename T> T Sqr(T x) { return(x*x); }
string plural(string s) { return(Sz(s) && s[Sz(s)-1]=='x' ? s+"en" : s+"s"); }
const int INF = (int)1e9;
const LD EPS = 1e-9;
const LD PI = acos(-1.0);
//#if DEBUG
#define GETCHAR getchar
/*#else
#define GETCHAR getchar_unlocked
#endif*/
bool Read(int &x)
{
char c,r=0,n=0;
x=0;
for(;;)
{
c=GETCHAR();
if ((c<0) && (!r))
return(0);
if ((c=='-') && (!r))
n=1;
else
if ((c>='0') && (c<='9'))
x=x*10+c-'0',r=1;
else
if (r)
break;
}
if (n)
x=-x;
return(1);
}
#define LIM 400005
int N,SZ;
char S[LIM],C[LIM];
int sum[LIM][26];
int sz,P[20][LIM];
pair<PR,int> V[LIM];
int O[LIM],ind[LIM];
vector<int> Q[LIM],A[LIM],B[LIM];
int BLT[(1<<18)+1];
void BuildSuffixArray()
{
int i,s;
if (N==1)
{
sz=1;
P[0][0]=0;
return;
}
Fox(i,N)
P[0][i]=S[i];
for (sz=s=1; s<N; sz++,s<<=1)
{
Fox(i,N)
V[i]=mp(mp(P[sz-1][i],(i+s<N ? P[sz-1][i+s] : -1)),i);
sort(V,V+N);
Fox(i,N)
if ((i) && (V[i].x==V[i-1].x))
P[sz][V[i].y]=P[sz][V[i-1].y];
else
P[sz][V[i].y]=i;
}
}
void Update(int i, int v)
{
while (i<=SZ)
{
BLT[i]+=v;
i+=(i&-i);
}
}
int Query(int k)
{
int i=0,b=SZ,t;
while ((b) && (i<SZ))
{
t=i+b;
if (k>=BLT[t])
{
i=t;
k-=BLT[t];
}
b>>=1;
}
return(i);
}
int main()
{
if (DEBUG)
freopen("in.txt","r",stdin);
int T,t;
int M;
int i,j,k,c,s;
LL ans[26];
Read(T);
Fox1(t,T)
{
Read(N),Read(M);
scanf("%s%s",&S,&C);
Fox(i,M)
{
Read(j),Read(k);
Q[j].pb(k);
}
Fill(sum,0);
Fox1(i,N)
Fox(j,26)
sum[i][j]=sum[i-1][j]+bool(S[i-1]=='A'+j);
BuildSuffixArray();
Fox(i,N)
{
O[i]=P[sz-1][i];
ind[O[i]]=i;
}
j=k=1;
FoxR(i,N)
{
j++,k++;
if (C[i]=='G')
j=1;
if (C[i]=='R')
k=1;
if (j<k)
{
A[j].pb(O[i]);
B[k].pb(O[i]);
}
}
Fill(BLT,0),s=0;
for (SZ=1; SZ<N; SZ<<=1);
Fill(ans,0);
Fox1(i,N)
{
Fox(j,Sz(A[i]))
Update(A[i][j]+1,1),s++;
Fox(j,Sz(B[i]))
Update(B[i][j]+1,-1),s--;
Fox(j,Sz(Q[i]))
{
k=ind[Query(Q[i][j]-1)];
Fox(c,26)
ans[c]+=sum[k+i][c]-sum[k][c];
}
}
printf("Case #%d:",t);
Fox(i,26)
printf(" %lld",ans[i]);
printf("\n");
Fox1(i,N+1)
{
A[i].clear();
B[i].clear();
Q[i].clear();
}
}
return(0);
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374<p>You have a string <strong>S</strong> consisting of <strong>N</strong> uppercase letters. This is no ordinary string, however — it's a rainbow string! Every letter has a colour, one of red, green, or blue (it might be ambitious to call this a rainbow, but close enough). The colour of the <strong>i</strong>th letter in <strong>S</strong> is indicated by the <strong>i</strong>th letter in a secondary string <strong>C</strong> (which also consists of <strong>N</strong> uppercase letters), with the three possible values "R", "G", and "B" representing the colors red, green, and blue respectively.</p>
<p>You'd like to answer <strong>Q</strong> questions about your rainbow string. The <strong>i</strong>th question asks:</p>
<p>"What's the {<strong>K<sub>i</sub></strong>}th lexicographically smallest substring of <strong>S</strong> which has length <strong>L<sub>i</sub></strong>, includes at least one green letter, and includes no red letters?"</p>
<p>Note that, when considering the list of valid substrings of which to determine the {<strong>K<sub>i</sub></strong>}th lexicographically smallest one, substrings which are equal to one another but occur at different positions in <strong>S</strong> are distinct! Additionally, <strong>K<sub>i</sub></strong> is guaranteed to be no larger than the number of such valid substrings.</p>
<p>For example, consider <strong>S</strong> = "ABABAB", <strong>C</strong> = "GGBGRG", and <strong>L<sub>i</sub></strong> = 2. The lexicographically-sorted list of valid substrings of <strong>S</strong> (those which have length 2, include at least one green letter, and include no red letters) is as follows:</p>
<ol><li> AB (starting at index 1) </li><li> AB (starting at index 3) </li><li> BA (starting at index 2) </li></ol>
<p>Therefore, if <strong>K<sub>i</sub></strong> = 2, the answer would be "AB". <strong>K<sub>i</sub></strong> can be no larger than 3 in this example.</p>
<p>To reduce the size of the output, you should simply output 26 integers, with the <strong>i</strong>th of them being the total number of times that the <strong>i</strong>th letter of the alphabet appears throughout the answers to the <strong>Q</strong> questions.</p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of rainbow strings you own.For each rainbow string, there is first a line containing the space-separated integers <strong>N</strong> and <strong>Q</strong>. The second line contains the length-<strong>N</strong> string <strong>S</strong> denoting the alphabetic characters in the rainbow string.The third line contains the length-<strong>N</strong> string <strong>C</strong> denoting the colours of each letter of the rainbow string, as described above.Then, <strong>Q</strong> more lines follow, the <strong>i</strong>th of which contains the space-separated integers<strong>L<sub>i</sub></strong> and <strong>K<sub>i</sub></strong>.</p>
<h3>Output</h3><p>For the <strong>i</strong>th rainbow string, print a line containing "Case #<strong>i</strong>: " followed by26 space-separated integers denoting the frequency of each letter amongst the answers to all of the questions, as described above.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 55 <br />1 ≤ <strong>N</strong> ≤ 200,000 <br />1 ≤ <strong>Q</strong> ≤ 400,000 <br />1 ≤ <strong>L<sub>i</sub></strong>, <strong>K<sub>i</sub></strong> ≤ <strong>N</strong> <br /></p>
<h3>Explanation of Sample</h3><p>For the first string, the answers to the three questions are "AB", "AB", and "BA" respectively. "A" and "B" each show up 3 times in these answers.</p>123version https://git-lfs.github.com/spec/v1oid sha256:5caaaca7f67c1ec5f9fdb62438a6b58e0957da6c9b9bcfe9a89320d5f41b221bsize 361480461234567891011121314151617181920212223242526272829303132333435// RAINBOW STRING // Official Solution by Jacob Plachta #define DEBUG 0#include #include #include #include #include #include #include #include#include #include #include #include #include #include #include #include#include #include #include #include #include #include using namespacestd; #define LL long long #define LD long double #define PR pair #defineFox(i,n) for (i=0; i=0; i--) #define FoxR1(i,n) for (i=n; i>0; i--) #defineFoxRI(i,a,b) for (i=b; i>=a; i--) #define Foxen(i,s) for (i=s.begin();i!=s.end(); i++) #define Min(a,b) a=min(a,b) #define Max(a,b) a=max(a,b)#define Sz(s) int((s).size()) #define All(s) (s).begin(),(s).end() #defineFill(s,v) memset(s,v,sizeof(s)) #define pb push_back #define mp make_pair#define x first #define y second template T Abs(T x) { return(x<0 ? -x : x); }template T Sqr(T x) { return(x*x); } string plural(string s) { return(Sz(s) &&s[Sz(s)-1]=='x' ? s+"en" : s+"s"); } const int INF = (int)1e9; const LD EPS =1e-9; const LD PI = acos(-1.0); //#if DEBUG #define GETCHAR getchar /*#else#define GETCHAR getchar_unlocked #endif*/ bool Read(int &x) { char c,r=0,n=0;x=0; for(;;) { c=GETCHAR(); if ((c<0) && (!r)) return(0); if ((c=='-') &&(!r)) n=1; else if ((c>='0') && (c<='9')) x=x*10+c-'0',r=1; else if (r) break;} if (n) x=-x; return(1); } #define LIM 400005 int N,SZ; char S[LIM],C[LIM];int sum[LIM][26]; int sz,P[20][LIM]; pair V[LIM]; int O[LIM],ind[LIM]; vectorQ[LIM],A[LIM],B[LIM]; int BLT[(1<<18)+1]; void BuildSuffixArray() { int i,s;if (N==1) { sz=1; P[0][0]=0; return; } Fox(i,N) P[0][i]=S[i]; for (sz=s=1;s=BLT[t]) { i=t; k-=BLT[t]; } b>>=1; } return(i); } int main() { if (DEBUG)freopen("in.txt","r",stdin); int T,t; int M; int i,j,k,c,s; LL ans[26];Read(T); Fox1(t,T) { Read(N),Read(M); scanf("%s%s",&S,&C); Fox(i,M) {Read(j),Read(k); Q[j].pb(k); } Fill(sum,0); Fox1(i,N) Fox(j,26)sum[i][j]=sum[i-1][j]+bool(S[i-1]=='A'+j); BuildSuffixArray(); Fox(i,N) {O[i]=P[sz-1][i]; ind[O[i]]=i; } j=k=1; FoxR(i,N) { j++,k++; if (C[i]=='G')j=1; if (C[i]=='R') k=1; if (j<k) { A[j].pb(O[i]); B[k].pb(O[i]); } }Fill(BLT,0),s=0; for (SZ=1; SZ<N; SZ<<=1); Fill(ans,0); Fox1(i,N) {Fox(j,Sz(A[i])) Update(A[i][j]+1,1),s++; Fox(j,Sz(B[i]))Update(B[i][j]+1,-1),s--; Fox(j,Sz(Q[i])) { k=ind[Query(Q[i][j]-1)]; Fox(c,26)ans[c]+=sum[k+i][c]-sum[k][c]; } } printf("Case #%d:",t); Fox(i,26) printf("%lld",ans[i]); printf("\n"); Fox1(i,N+1) { A[i].clear(); B[i].clear();Q[i].clear(); } } return(0); }
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455Case #1: 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #2: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 2 1Case #3: 4 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #4: 0 4 5 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #5: 2 0 0 0 5 1 0 4 2 0 0 6 0 1 1 4 0 3 2 0 3 0 0 2 0 0Case #6: 1800394884 1802832417 1793020429 1784518799 1799345123 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #7: 888902752 904468691 893529395 897751512 893232315 892695959 899417851 902076108 911072872 906154553 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #8: 602883957 595900410 597504983 598097887 602331755 595937381 599850972 605321561 597756061 603017268 604877105 599816420 594866205 593841972 604487422 0 0 0 0 0 0 0 0 0 0 0Case #9: 449262396 455339905 446579889 442836921 446732134 456140364 451984406 449279394 448055252 445082037 442681599 446560226 443495791 444335601 453758567 442816726 448875204 461388263 453568368 450892519 0 0 0 0 0 0Case #10: 362734717 356797029 362420129 355379039 362647914 360021084 367533338 358855506 362010484 363035142 365997177 359315548 352137515 361105089 355689142 354807813 362607239 360693340 365062532 357276206 362251472 364673006 355908859 356801139 354970727 0Case #11: 4994059477 5018965861 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #12: 340918 346742 327409 347201 349189 371201 324714 346187 383274 330513 337701 351541 317340 327355 382018 330691 303110 345390 351286 321965 340190 0 0 0 0 0Case #13: 3165702 3018300 3071273 3024704 2837898 2996624 2983146 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #14: 1021377 1094437 1063507 1022044 1044195 1010305 1003797 1047336 1092901 931660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #15: 80559 76872 78059 83750 84743 83115 83710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #16: 3892253 4084620 3985726 4156919 4051722 4110669 3916991 3914046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #17: 11457335 11470429 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #18: 1744370 1835076 1889543 1654299 1732109 1853297 1705906 1880374 1737749 1857258 1783627 1792871 1851246 1725367 1917607 1949037 1827872 1845265 0 0 0 0 0 0 0 0Case #19: 1660300 1555949 1761755 1671815 1667682 1803687 1715507 1863850 1656573 1711085 1836236 1812852 1567040 1688755 1745852 1782963 1689055 1636122 1662503 0 0 0 0 0 0 0Case #20: 1416752 1563079 1361014 1488966 1557828 1482193 1505994 1377289 1554380 1545956 1495017 1513785 1448778 1533916 1344579 1376241 1512701 1359978 1421097 1453364 1461118 1464286 0 0 0 0Case #21: 1721600 1755180 1758091 1780830 1772424 1734019 1687412 1893007 1673223 1830295 1875594 1790124 2011786 1788215 1733149 1794390 1851658 1740544 0 0 0 0 0 0 0 0Case #22: 902953 883772 834340 919344 838520 825525 934517 955559 838646 836655 861197 920718 873047 892824 873501 892668 900554 879579 882754 915565 917578 960119 800962 992517 0 0Case #23: 718918 713488 686170 823855 767795 761531 702003 759530 727655 723510 756104 772890 706065 758097 735543 820794 770150 750435 0 0 0 0 0 0 0 0Case #24: 2215269 2471703 2378905 2353105 2489347 2443961 2414550 2186423 2371485 2313976 2269641 2275919 2272650 2312655 0 0 0 0 0 0 0 0 0 0 0 0Case #25: 6371177 6641571 6350310 6339817 6786852 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #26: 2194988 2075734 2197102 2243057 2114239 2072055 2014120 2029121 2269837 2235066 2101081 2165929 2055496 2175630 2112358 0 0 0 0 0 0 0 0 0 0 0Case #27: 6417032 6585008 6474142 6472371 6650061 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #28: 16205772 15879475 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #29: 1403571 1440546 1463710 1541267 1564377 1556046 1402326 1492235 1426631 1545493 1481115 1548259 1619761 1723274 1531017 1464049 1453847 1505313 1444306 1540127 1528213 0 0 0 0 0Case #30: 1018251 995707 1001928 990033 1060084 977805 964569 1136894 1085280 983327 1036444 1007464 1020928 1036236 983428 1080608 975617 975175 1027868 1011267 993687 985898 981523 0 0 0Case #31: 3095827 3319516 3398029 3130195 3167281 3384567 3426835 3215121 3308415 3276371 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #32: 1102642 1060722 1114314 1141183 1108949 1053204 1195753 1181686 1050041 1099552 1113264 1092740 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #33: 1045182 1174407 1091798 1110385 1086051 1073362 1178253 1092122 935355 1220734 1087117 1133763 1048717 1054121 1051068 1098818 1171386 1125355 1020074 1011672 1008490 1019115 1108632 0 0 0Case #34: 2641707 2770013 2770250 2758080 2609751 2528161 2642965 2630155 2731932 2794067 2781625 2661673 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #35: 4588367 4660473 4628410 4497854 4820193 4699431 4806861 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #36: 6131573 6386142 6258355 6548662 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #37: 1470728 1419459 1473656 1359793 1298638 1397055 1441325 1440864 1441047 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #38: 1350517 1244014 1419151 1383773 1361799 1363102 1341243 1420809 1287215 1448116 1418098 1406936 1262016 1290928 1396966 1314475 1294742 1360182 1322001 1575357 1449756 1421414 0 0 0 0Case #39: 6371638 6586117 6374292 6188606 6327646 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #40: 839371 773666 879634 852858 810000 796615 832491 805001 766538 754625 748845 841410 817509 767550 848030 834304 784120 827899 828641 0 0 0 0 0 0 0Case #41: 1937709 1706655 1731369 1708423 1811238 1789324 1858943 1736742 1706988 1713956 1849580 1723817 1726125 1883462 1876555 1766985 1724746 1968559 0 0 0 0 0 0 0 0Case #42: 1186423 1499211 1226978 1332973 1268981 1269136 1319006 1443145 1262711 1218344 1301444 1360281 1427378 1319571 1384304 1245295 1331480 1378204 1201858 1265527 1254850 1284896 1137665 1371970 1318752 0Case #43: 1455669 1460121 1536469 1555505 1452509 1610743 1530440 1510239 1487419 1452089 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #44: 1915089 2077209 1831142 1988933 1875495 2004089 1881367 1841896 1911355 1822107 1868607 1774889 1886392 1920671 1927951 1960229 1832563 0 0 0 0 0 0 0 0 0Case #45: 1754299 1545936 1760071 1636572 1650452 1736246 1693962 1649654 1727603 1806261 1671665 1936749 1657881 1674012 1694745 1769100 1724258 1714180 1654849 0 0 0 0 0 0 0Case #46: 2227943 2257851 2226437 2166293 2298582 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #47: 4324533 3951619 4249470 4059465 3861448 4015256 3956060 4026672 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #48: 1933351 1984411 2021930 1910990 1970700 2149896 2064937 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #49: 1656841 1585957 1664807 1630351 1664246 1741778 1522185 1658950 1817000 1685327 1653558 1489916 1635841 0 0 0 0 0 0 0 0 0 0 0 0 0Case #50: 2842441 2749044 2946989 2920450 3043601 2784560 2872556 2973457 2927459 2952760 2912106 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0Case #51: 1788465 1586372 1583688 1727602 1621990 1587440 1603734 1650433 1605602 1746090 1655639 1752279 1600150 1507796 1618167 1646875 1603254 1622324 1664828 1553974 0 0 0 0 0 0Case #52: 1249435 1253284 1177024 1246457 1180139 1083894 1199215 1241537 1183436 1268842 1230735 1310861 1411007 1212438 1195959 1292895 1264430 1210162 1190286 1262560 1107222 1161271 1287835 1276168 1266413 1212577Case #53: 2107921 1987795 2093254 2132277 2015773 2095931 2058465 2007524 2028631 2124490 2117591 2080745 2090379 2073763 0 0 0 0 0 0 0 0 0 0 0 0Case #54: 1175161 1099686 1187860 1090923 1166077 1182912 1213924 1165028 1220507 1177167 1131438 1141264 1234346 1247758 1267561 1246257 1163188 1153208 1195300 1318261 1211384 1170148 0 0 0 0Case #55: 2390180 2353002 2639807 2442670 2494834 2601010 2512919 2582302 2455633 2343861 2544627 2262470 2397541 0 0 0 0 0 0 0 0 0 0 0 0 0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200// RNG
// Official Solution by Jacob Plachta
#define DEBUG 0
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
using namespace std;
#define LL long long
#define LD long double
#define PR pair<int,int>
#define Fox(i,n) for (i=0; i<n; i++)
#define Fox1(i,n) for (i=1; i<=n; i++)
#define FoxI(i,a,b) for (i=a; i<=b; i++)
#define FoxR(i,n) for (i=(n)-1; i>=0; i--)
#define FoxR1(i,n) for (i=n; i>0; i--)
#define FoxRI(i,a,b) for (i=b; i>=a; i--)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define Sz(s) int((s).size())
#define All(s) (s).begin(),(s).end()
#define Fill(s,v) memset(s,v,sizeof(s))
#define pb push_back
#define mp make_pair
#define x first
#define y second
template<typename T> T Abs(T x) { return(x<0 ? -x : x); }
template<typename T> T Sqr(T x) { return(x*x); }
string plural(string s) { return(Sz(s) && s[Sz(s)-1]=='x' ? s+"en" : s+"s"); }
const int INF = (int)1e9;
const LD EPS = 1e-9;
const LD PI = acos(-1.0);
//#if DEBUG
#define GETCHAR getchar
/*#else
#define GETCHAR getchar_unlocked
#endif*/
bool Read(int &x)
{
char c,r=0,n=0;
x=0;
for(;;)
{
c=GETCHAR();
if ((c<0) && (!r))
return(0);
if ((c=='-') && (!r))
n=1;
else
if ((c>='0') && (c<='9'))
x=x*10+c-'0',r=1;
else
if (r)
break;
}
if (n)
x=-x;
return(1);
}
int main()
{
if (DEBUG)
freopen("in.txt","r",stdin);
int TT,tt;
int N,M,K,T,R;
LD P;
int i,j,k,b;
LD d,v;
int S[20];
static int up[100000],down[100000],dist[100000],dir[20][20];
static vector<int> con[100000];
static LD exRN[100001],exNR[100001],exP[100001],exT[100001];
static LD dyn[1<<20][21];
queue<int> Q;
Read(TT);
Fox1(tt,TT)
{
//input
Read(N),Read(M),Read(K),Read(T),Read(R);
Fox(i,N)
con[i].clear();
cin >> P;
Fox(i,K)
Read(S[i]),S[i]--;
while (M--)
{
Read(i),Read(j);
con[i-1].pb(j-1);
}
Fox(i,K)
dyn[(1<<K)-1][i]=0;
//dist from start to each item
Fill(up,-1);
Q.push(0),up[0]=0;
while (!Q.empty())
{
i=Q.front(),Q.pop();
Fox(j,Sz(con[i]))
if (up[k=con[i][j]]<0)
Q.push(k),up[k]=up[i]+1;
}
//dist from each item to other items and to nearest leaf
Fill(down,-1);
Fox(b,K)
{
Fill(dist,-1);
Q.push(S[b]),dist[S[b]]=0;
while (!Q.empty())
{
i=Q.front(),Q.pop();
if ((!Sz(con[i])) && (down[b]<0))
down[b]=dist[i];
Fox(j,Sz(con[i]))
if (dist[k=con[i][j]]<0)
Q.push(k),dist[k]=dist[i]+1;
}
Fox(i,K)
dir[b][i]=dist[S[i]];
}
//expected times for root -> node
exRN[0]=0;
Fox1(i,N)
{
v=(P*T + (1-P)*(R+exRN[i-1])) / P;
exRN[i]=exRN[i-1]+v;
}
//expected times for node -> root
exNR[0]=R;
Fox1(i,N)
exNR[i]=P*(T + exNR[i-1]) + (1-P)*R;
//conditional expected times for node -> node
exP[0]=1;
exT[0]=0;
Fox1(i,N)
{
exP[i]=exP[i-1]*P;
exT[i]=exT[i-1] + exP[i-1]*(1-P)*((i-1)*T + R);
}
//bitmask DP
FoxR(b,(1<<K)-1)
{
d=-1;
Fox(i,K)
if (!(b&(1<<i)))
{
v=dyn[b][i]=dyn[b|(1<<i)][i];
v+=exRN[up[S[i]]];
if ((d<0) || (d>v))
d=v;
}
dyn[b][K]=d;
Fox(i,K)
if (b&(1<<i))
{
d=exNR[down[i]]+dyn[b][K];
Fox(j,K)
if (!(b&(1<<j)))
if (dir[i][j]>=0)
{
k=dir[i][j];
v=exP[k]*(k*T + dyn[b][j]) + exT[k] + (1-exP[k])*dyn[b][K];
Min(d,v);
}
dyn[b][i]=d;
}
}
//output
printf("Case #%d: ",tt);
cout << fixed << setprecision(9) << dyn[0][K] << endl;
}
return(0);
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566<p>You're playing a video game that features <strong>N</strong> different areas, numbered from 1 to <strong>N</strong>. There are <strong>M</strong> one-way paths that each connect two areas. The <strong>i</strong>th path runs from area <strong>A<sub>i</sub></strong> to a different area <strong>B<sub>i</sub></strong>. No pair of paths directly connect the same pair of areas, and for every area it's impossible to start at that area and follow a non-empty sequence of paths to return to that area. In other words, the game's layout is a directed acyclic graph.</p>
<p>You start in area 1. <strong>K</strong> other distinct areas each contain an item to collect — the <strong>i</strong>th of these is area <strong>I<sub>i</sub></strong>. As soon as you've visited these <strong>K</strong> areas at least once each, you win! You'd like to do so as fast as possible.</p>
<p>At any point in time, if there are no outgoing paths leading away from your current area, you automatically respawn in area 1 after a delay of <strong>R</strong> seconds. Otherwise, you get to choose one such path and attempt to follow it. Unfortunately, this game relies entirely on Random Number Generation to determine whether or not you'll be successful,regardless of your skill. In particular, with probability <strong>P</strong>, you'll successfully travel along your chosen path for <strong>D</strong> seconds, ending up in a new area. On the other hand, with probability 1 - <strong>P</strong>, you'll instead perish and respawn in area 1 after a delay of <strong>R</strong> seconds.</p>
<p>What's the minimum expected time for you to collect all <strong>K</strong> items, given that you play optimally? This is guaranteed to be possible — that is, all <strong>K</strong> areas that contain items are reachable from area 1. Your output should have at most 10<sup>-6</sup> absolute or relative error.</p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of times you play the game.For each time, there is first a line containing the space-separated integers <strong>N</strong>, <strong>M</strong>, and <strong>K</strong>. The second line contains the space-separated integers <strong>D</strong> and <strong>R</strong>.The third line contains the real value <strong>P</strong> which is given with at most 4 decimal places.The fourth line contains the <strong>K</strong> space-separated integers <strong>I<sub>1</sub></strong> to <strong>I<sub>K</sub></strong>.Then, <strong>M</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers<strong>A<sub>i</sub></strong> and <strong>B<sub>i</sub></strong>.</p>
<h3>Output</h3><p>For the <strong>i</strong>th time you play the game, print a line containing "Case #<strong>i</strong>: " followed by the expected time it will take you to collect all of the itemsif you play optimally.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 50 <br />2 ≤ <strong>N</strong> ≤ 100,000 <br />1 ≤ <strong>M</strong> ≤ 100,000 <br />1 ≤ <strong>K</strong> ≤ min(20, <strong>N</strong> - 1) <br />0.5 ≤ <strong>P</strong> ≤ 1.0 <br />1 ≤ <strong>D</strong>, <strong>R</strong> ≤ 1,000 <br />1 ≤ <strong>A<sub>i</sub></strong>, <strong>B<sub>i</sub></strong> ≤ <strong>N</strong> <br />2 ≤ <strong>I<sub>i</sub></strong> ≤ <strong>N</strong> <br /></p>
<p>The answer for each game is guaranteed to be less than 10<sup>30</sup>.</p>
<h3>Explanation of Sample</h3><p>In the first game, it takes you 10 seconds to reach the only item, and then you win. There's no chance of failure.
The second game is the same as the first, but now you fail to reach the item with probability 0.5. On average you will fail once before reaching the item, so you'll incur an average penalty of 3 seconds on top of the 10 seconds it takes you to succeed, for a total of 13 seconds.</p>
123version https://git-lfs.github.com/spec/v1oid sha256:d64df27b7be563e8a345d0bd34860a0ff143bbbb8615f15f5242427d7f59e567size 23518602123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566You're playing a video game that features **N** different areas, numbered from1 to **N**. There are **M** one-way paths that each connect two areas. The**i**th path runs from area **Ai** to a different area **Bi**. No pair ofpaths directly connect the same pair of areas, and for every area it'simpossible to start at that area and follow a non-empty sequence of paths toreturn to that area. In other words, the game's layout is a directed acyclicgraph.
You start in area 1. **K** other distinct areas each contain an item tocollect — the **i**th of these is area **Ii**. As soon as you've visited these**K** areas at least once each, you win! You'd like to do so as fast aspossible.
At any point in time, if there are no outgoing paths leading away from yourcurrent area, you automatically respawn in area 1 after a delay of **R**seconds. Otherwise, you get to choose one such path and attempt to follow it.Unfortunately, this game relies entirely on Random Number Generation todetermine whether or not you'll be successful, regardless of your skill. Inparticular, with probability **P**, you'll successfully travel along yourchosen path for **D** seconds, ending up in a new area. On the other hand,with probability 1 - **P**, you'll instead perish and respawn in area 1 aftera delay of **R** seconds.
What's the minimum expected time for you to collect all **K** items, giventhat you play optimally? This is guaranteed to be possible — that is, all**K** areas that contain items are reachable from area 1. Your output shouldhave at most 10-6 absolute or relative error.
### Input
Input begins with an integer **T**, the number of times you play the game. Foreach time, there is first a line containing the space-separated integers**N**, **M**, and **K**. The second line contains the space-separated integers**D** and **R**. The third line contains the real value **P** which is givenwith at most 4 decimal places. The fourth line contains the **K** space-separated integers **I1** to **IK**. Then, **M** lines follow, the **i**th ofwhich contains the space-separated integers **Ai** and **Bi**.
### Output
For the **i**th time you play the game, print a line containing "Case #**i**:" followed by the expected time it will take you to collect all of the itemsif you play optimally.
### Constraints
1 ≤ **T** ≤ 50 2 ≤ **N** ≤ 100,000 1 ≤ **M** ≤ 100,000 1 ≤ **K** ≤ min(20, **N** \- 1) 0.5 ≤ **P** ≤ 1.0 1 ≤ **D**, **R** ≤ 1,000 1 ≤ **Ai**, **Bi** ≤ **N** 2 ≤ **Ii** ≤ **N**
The answer for each game is guaranteed to be less than 1030.
### Explanation of Sample
In the first game, it takes you 10 seconds to reach the only item, and thenyou win. There's no chance of failure. The second game is the same as thefirst, but now you fail to reach the item with probability 0.5. On average youwill fail once before reaching the item, so you'll incur an average penalty of3 seconds on top of the 10 seconds it takes you to succeed, for a total of 13seconds.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546Case #1: 10.000000000Case #2: 13.000000000Case #3: 2.000000000Case #4: 1004.000000000Case #5: 168.647230321Case #6: 5.000000000Case #7: 205153.000000000Case #8: 36458853456.878738891Case #9: 2055332.686437849Case #10: 59748.000000000Case #11: 1403028522515344.934448242Case #12: 10421061.425855338Case #13: 1188546.000000000Case #14: 87401480.806348593Case #15: 7405891.509676050Case #16: 57974.000000000Case #17: 242684.186821399Case #18: 595547.494966301Case #19: 2293360.000000000Case #20: 179291.144112032Case #21: 321865263.845019865Case #22: 18279.000000000Case #23: 101674943.588009080Case #24: 316857.275527182Case #25: 4164662.000000000Case #26: 54584390.156581200Case #27: 40624898564.638281569Case #28: 1750.000000000Case #29: 18450535.200870354Case #30: 12376454131045.286281586Case #31: 36879.000000000Case #32: 30397317959.283073163Case #33: 1408527396.723025701Case #34: 22608.000000000Case #35: 2198215868727194239631360.000000000Case #36: 30969290.657660188Case #37: 24910.000000000Case #38: 487617.875314213Case #39: 336930477.451522236Case #40: 84147.000000000Case #41: 6036579.688970289Case #42: 29155.558865047Case #43: 46501.000000000Case #44: 245951881.560804426Case #45: 353996.721532685Case #46: 6350.000000000123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178// SNAKE AND LADDER
// Official Solution by Jacob Plachta
#define DEBUG 0
#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
using namespace std;
#define LL long long
#define LD long double
#define PR pair<int,int>
#define Fox(i,n) for (i=0; i<n; i++)
#define Fox1(i,n) for (i=1; i<=n; i++)
#define FoxI(i,a,b) for (i=a; i<=b; i++)
#define FoxR(i,n) for (i=(n)-1; i>=0; i--)
#define FoxR1(i,n) for (i=n; i>0; i--)
#define FoxRI(i,a,b) for (i=b; i>=a; i--)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define Sz(s) int((s).size())
#define All(s) (s).begin(),(s).end()
#define Fill(s,v) memset(s,v,sizeof(s))
#define pb push_back
#define mp make_pair
#define x first
#define y second
template<typename T> T Abs(T x) { return(x<0 ? -x : x); }
template<typename T> T Sqr(T x) { return(x*x); }
string plural(string s) { return(Sz(s) && s[Sz(s)-1]=='x' ? s+"en" : s+"s"); }
const int INF = (int)1e9;
const LD EPS = 1e-9;
const LD PI = acos(-1.0);
//#if DEBUG
#define GETCHAR getchar
/*#else
#define GETCHAR getchar_unlocked
#endif*/
bool Read(int &x)
{
char c,r=0,n=0;
x=0;
for(;;)
{
c=GETCHAR();
if ((c<0) && (!r))
return(0);
if ((c=='-') && (!r))
n=1;
else
if ((c>='0') && (c<='9'))
x=x*10+c-'0',r=1;
else
if (r)
break;
}
if (n)
x=-x;
return(1);
}
bool ReadLL(LL &x)
{
char c,r=0,n=0;
x=0;
for(;;)
{
c=GETCHAR();
if ((c<0) && (!r))
return(0);
if ((c=='-') && (!r))
n=1;
else
if ((c>='0') && (c<='9'))
x=x*10+c-'0',r=1;
else
if (r)
break;
}
if (n)
x=-x;
return(1);
}
#define MOD 1000000007
int main()
{
if (DEBUG)
freopen("in.txt","r",stdin);
int T,t;
LL N;
int K;
int i,ans;
LL a,b,x,y;
static pair<LL,int> P[1000];
Read(T);
Fox1(t,T)
{
ReadLL(N),Read(K);
Fox(i,K)
ReadLL(P[i].x),Read(P[i].y);
if (K==2*N-1)
{
ans=1;
goto Done;
}
sort(P,P+K);
a=1,b=N;
Fox(i,K-1)
if ((P[i].x==P[i+1].x) && (P[i].x==a))
a++;
FoxR(i,K-1)
if ((P[i].x==P[i+1].x) && (P[i].x==b))
b--;
ans=0;
Fox(i,K-1)
if ((P[i].x==P[i+1].x) && (P[i].x>=a) && (P[i].x<=b))
goto Done;
x=-1;
Fox(i,K)
if ((P[i].x>=a) && (P[i].x<=b))
if (x<0)
x=y=P[i].x;
else
{
if ((P[i].x-y)%2==(P[i].y+P[i-1].y)%2)
goto Done;
y=P[i].x;
}
if (x<0)
{
N=b-a+1;
if (N==1)
ans=2;
else
{
N=(N-1)%MOD;
ans=(4+2*N*(N+1))%MOD;
}
}
else
{
a=max(1LL,x-a);
b=max(1LL,b-y);
ans=2*(a%MOD)*(b%MOD)%MOD;
}
Done:;
printf("Case #%d: %d\n",t,ans);
}
return(0);
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748<p>Some time has passed since you took in the local population of snakes, feeding them every day and allowing them to live peacefully amongst your ladders. Unfortunately, your neighbours have not been thrilled about living next to billions of serpents, so they've filed complaints to the mayor! As a result, almost all of your snakes and ladders have been forcibly evicted, leaving you with only one of each for company.</p>
<p>Your ladder has <strong>N</strong> horizontal rungs, numbered 1 to <strong>N</strong> from bottom to top. Like all ladders, it also has 2 vertical rails, with rail 1 on the left and rail 2 on the right. To improve its appearance, you've allowed some plants to grow all over it. Notably, there are <strong>K</strong> flowers at distinct locations on the ladder, with the ith flower at the intersection of rung <strong>R_i</strong> and rail <strong>C_i</strong>.</p>
<p>Your snake loves to sleep on the ladder. It always places its head at the intersection of some rung and some rail, and from there, each subsequent segment of its body extends up, down, left, or right to follow a rung or rail to another intersection. The snake likes to be spread out, but hates touching flowers, so it insists that the path that its body takes must not touch any intersection more than once, and must not touch any intersection that has a flower. Conveniently, the snake is exactly long enough to theoretically pass through all intersections that don't have flowers — that is, if consecutive rungs and rails are 1 unit apart from one another, then the snake has a length of 2 * <strong>N</strong> - <strong>K</strong> - 1 units. Note that your snake may have 0 length (in which case it'll only occupy a single intersection).</p>
<p>The diagram below (which corresponds to the fourth sample case) illustrates a valid way in which the snake can arrange itself on a ladder with 4 rungs and 1 flower:</p>
<center><img src="{{PHOTO_ID:191658972183607}}" /></center>
<p>Can you help your snake count the number of different ways in which it can position itself on the ladder, such that it covers all of the intersections which don't contain flowers? An arrangement of the snake is defined by an ordered sequence of intersections that it passes through, starting from its head. You only need to compute the answer modulo 10<sup>9</sup> + 7.<p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of ladders.For each ladder, there is first a line containing the space-separated integers <strong>N</strong> and <strong>K</strong>. Then <strong>K</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers<strong>R<sub>i</sub></strong> and <strong>C<sub>i</sub></strong> .</p>
<h3>Output</h3><p>For the <strong>i</strong>th ladder, print a line containing "Case #<strong>i</strong>: " followed by the number of ways in which the snake can be arranged, modulo 10<sup>9</sup> + 7.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 555 <br />1 ≤ <strong>N</strong> ≤ 10<sup>12</sup> <br />0 ≤ <strong>K</strong> ≤ min(1000, 2 * <strong>N</strong> - 1) <br />1 ≤ <strong>R<sub>i</sub></strong> ≤ <strong>N</strong> <br />1 ≤ <strong>C<sub>i</sub></strong> ≤ 2 <br /></p>
<h3>Explanation of Sample</h3><p>For the first ladder, the snake can place its head in any of the 4 intersections, and from each one it can arrange itself in 2 ways for 8 ways total.
For the second ladder, the flowers prevent the snake from crossing from the top 2 intersections to the bottom 2 (or vice versa).
For the third ladder, there are 2 possible intersections at which the snake can place its head which yield 1 valid arrangement each.</p>12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667Some time has passed since you took in the local population of snakes, feedingthem every day and allowing them to live peacefully amongst your ladders.Unfortunately, your neighbours have not been thrilled about living next tobillions of serpents, so they've filed complaints to the mayor! As a result,almost all of your snakes and ladders have been forcibly evicted, leaving youwith only one of each for company.
Your ladder has **N** horizontal rungs, numbered 1 to **N** from bottom totop. Like all ladders, it also has 2 vertical rails, with rail 1 on the leftand rail 2 on the right. To improve its appearance, you've allowed some plantsto grow all over it. Notably, there are **K** flowers at distinct locations onthe ladder, with the ith flower at the intersection of rung **R_i** and rail**C_i**.
Your snake loves to sleep on the ladder. It always places its head at theintersection of some rung and some rail, and from there, each subsequentsegment of its body extends up, down, left, or right to follow a rung or railto another intersection. The snake likes to be spread out, but hates touchingflowers, so it insists that the path that its body takes must not touch anyintersection more than once, and must not touch any intersection that has aflower. Conveniently, the snake is exactly long enough to theoretically passthrough all intersections that don't have flowers — that is, if consecutiverungs and rails are 1 unit apart from one another, then the snake has a lengthof 2 * **N** \- **K** \- 1 units. Note that your snake may have 0 length (inwhich case it'll only occupy a single intersection).
The diagram below (which corresponds to the fourth sample case) illustrates avalid way in which the snake can arrange itself on a ladder with 4 rungs and 1flower:

Can you help your snake count the number of different ways in which it canposition itself on the ladder, such that it covers all of the intersectionswhich don't contain flowers? An arrangement of the snake is defined by anordered sequence of intersections that it passes through, starting from itshead. You only need to compute the answer modulo 109 \+ 7.
### Input
Input begins with an integer **T**, the number of ladders. For each ladder,there is first a line containing the space-separated integers **N** and **K**.Then **K** lines follow, the **i**th of which contains the space-separatedintegers **Ri** and **Ci** .
### Output
For the **i**th ladder, print a line containing "Case #**i**: " followed bythe number of ways in which the snake can be arranged, modulo 109 \+ 7.
### Constraints
1 ≤ **T** ≤ 555 1 ≤ **N** ≤ 1012 0 ≤ **K** ≤ min(1000, 2 * **N** \- 1) 1 ≤ **Ri** ≤ **N** 1 ≤ **Ci** ≤ 2
### Explanation of Sample
For the first ladder, the snake can place its head in any of the 4intersections, and from each one it can arrange itself in 2 ways for 8 waystotal. For the second ladder, the flowers prevent the snake from crossing fromthe top 2 intersections to the bottom 2 (or vice versa). For the third ladder,there are 2 possible intersections at which the snake can place its head whichyield 1 valid arrangement each.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529Case #1: 8Case #2: 0Case #3: 2Case #4: 6Case #5: 267684459Case #6: 2Case #7: 0Case #8: 8Case #9: 16Case #10: 18Case #11: 18Case #12: 18Case #13: 18Case #14: 2Case #15: 0Case #16: 1Case #17: 1Case #18: 2Case #19: 2Case #20: 2Case #21: 8Case #22: 16Case #23: 28Case #24: 44Case #25: 98014004Case #26: 98042008Case #27: 98070016Case #28: 98098028Case #29: 909245781Case #30: 652060217Case #31: 640977384Case #32: 664530208Case #33: 830548492Case #34: 593512656Case #35: 95307137Case #36: 0Case #37: 604780714Case #38: 332205830Case #39: 0Case #40: 760227240Case #41: 707565303Case #42: 507887797Case #43: 0Case #44: 675464678Case #45: 237893333Case #46: 774092646Case #47: 705417745Case #48: 861683936Case #49: 819675549Case #50: 0Case #51: 65522041Case #52: 895571761Case #53: 499418590Case #54: 43777910Case #55: 0Case #56: 343296341Case #57: 147476799Case #58: 713920914Case #59: 704481609Case #60: 0Case #61: 0Case #62: 172783726Case #63: 0Case #64: 143935999Case #65: 318798746Case #66: 958416440Case #67: 45952558Case #68: 147032920Case #69: 499410723Case #70: 691849712Case #71: 245335333Case #72: 72749514Case #73: 273939493Case #74: 918544373Case #75: 582144162Case #76: 294768758Case #77: 308107401Case #78: 2919666Case #79: 657198556Case #80: 0Case #81: 788507080Case #82: 447769122Case #83: 630995283Case #84: 0Case #85: 0Case #86: 191460004Case #87: 122517351Case #88: 522940385Case #89: 501725431Case #90: 679753068Case #91: 244495234Case #92: 951991239Case #93: 732415762Case #94: 422292557Case #95: 61549734Case #96: 360169582Case #97: 925804013Case #98: 0Case #99: 994778343Case #100: 69156121Case #101: 0Case #102: 300391736Case #103: 958830160Case #104: 452633311Case #105: 457669197Case #106: 376869966Case #107: 0Case #108: 513749492Case #109: 807217730Case #110: 886568136Case #111: 139597240Case #112: 0Case #113: 396876954Case #114: 746206746Case #115: 885654099Case #116: 630331049Case #117: 975485053Case #118: 688222729Case #119: 346345463Case #120: 0Case #121: 0Case #122: 790872124Case #123: 935207703Case #124: 293638348Case #125: 275610200Case #126: 426278656Case #127: 416495665Case #128: 970191878Case #129: 921587161Case #130: 278640938Case #131: 959969592Case #132: 641068641Case #133: 139676810Case #134: 882444364Case #135: 430504155Case #136: 454462189Case #137: 914657446Case #138: 41279830Case #139: 761870044Case #140: 943943216Case #141: 761613990Case #142: 262356424Case #143: 402162776Case #144: 0Case #145: 562337640Case #146: 364610077Case #147: 108051083Case #148: 611455117Case #149: 684453493Case #150: 481874285Case #151: 428459757Case #152: 332184810Case #153: 658304372Case #154: 229790800Case #155: 567392000Case #156: 496522976Case #157: 0Case #158: 0Case #159: 0Case #160: 0Case #161: 676773738Case #162: 960386728Case #163: 962907235Case #164: 0Case #165: 75611083Case #166: 87681450Case #167: 0Case #168: 652700874Case #169: 209976709Case #170: 825356878Case #171: 469939765Case #172: 0Case #173: 82338254Case #174: 658729214Case #175: 845914542Case #176: 81692108Case #177: 491954794Case #178: 0Case #179: 825554855Case #180: 477679890Case #181: 286250721Case #182: 40811605Case #183: 138857396Case #184: 748613548Case #185: 0Case #186: 0Case #187: 944211872Case #188: 0Case #189: 225408143Case #190: 247861419Case #191: 953196418Case #192: 624462018Case #193: 970680424Case #194: 738460795Case #195: 0Case #196: 895052726Case #197: 756372468Case #198: 606229787Case #199: 371816412Case #200: 842451044Case #201: 220141336Case #202: 800719178Case #203: 235949736Case #204: 0Case #205: 177925702Case #206: 562911889Case #207: 603198078Case #208: 40086251Case #209: 326382560Case #210: 277267864Case #211: 284812709Case #212: 486202725Case #213: 426376568Case #214: 0Case #215: 40152230Case #216: 553261654Case #217: 964315920Case #218: 553087553Case #219: 333254442Case #220: 529531478Case #221: 24261383Case #222: 318643376Case #223: 940051082Case #224: 326129598Case #225: 0Case #226: 793791006Case #227: 417084080Case #228: 905212208Case #229: 0Case #230: 0Case #231: 685393114Case #232: 855249209Case #233: 765663196Case #234: 584891224Case #235: 645360648Case #236: 66127536Case #237: 891920879Case #238: 366785354Case #239: 587172380Case #240: 195409335Case #241: 822773861Case #242: 660719310Case #243: 939251564Case #244: 40786136Case #245: 383182350Case #246: 355063659Case #247: 436113052Case #248: 368586153Case #249: 628864869Case #250: 796225384Case #251: 809365615Case #252: 244554406Case #253: 366323087Case #254: 0Case #255: 493329784Case #256: 796983253Case #257: 0Case #258: 788852534Case #259: 341785459Case #260: 998294526Case #261: 450123132Case #262: 417260929Case #263: 564979650Case #264: 745495271Case #265: 932721844Case #266: 101881099Case #267: 570596011Case #268: 225089623Case #269: 583785117Case #270: 867381945Case #271: 2Case #272: 0Case #273: 206522367Case #274: 876681220Case #275: 622910845Case #276: 855819395Case #277: 89649016Case #278: 339753503Case #279: 962820568Case #280: 794370470Case #281: 924563005Case #282: 735879783Case #283: 645696679Case #284: 0Case #285: 0Case #286: 23539975Case #287: 641175092Case #288: 710321213Case #289: 258478632Case #290: 241279884Case #291: 469676919Case #292: 387988404Case #293: 0Case #294: 0Case #295: 91144251Case #296: 939738738Case #297: 962156034Case #298: 128841555Case #299: 635008989Case #300: 599117317Case #301: 0Case #302: 264013430Case #303: 0Case #304: 520442866Case #305: 255620317Case #306: 358385903Case #307: 569292909Case #308: 0Case #309: 916864460Case #310: 416230742Case #311: 841936774Case #312: 671189281Case #313: 0Case #314: 668100766Case #315: 83628423Case #316: 2Case #317: 834739165Case #318: 0Case #319: 111433604Case #320: 393135188Case #321: 0Case #322: 283357712Case #323: 0Case #324: 866449438Case #325: 574883496Case #326: 983486412Case #327: 278390125Case #328: 824179968Case #329: 448191118Case #330: 500425853Case #331: 0Case #332: 875783660Case #333: 236627763Case #334: 997353018Case #335: 885094022Case #336: 684451879Case #337: 280831597Case #338: 277072734Case #339: 198980978Case #340: 279385770Case #341: 0Case #342: 56561616Case #343: 0Case #344: 0Case #345: 214330679Case #346: 0Case #347: 338369590Case #348: 446992830Case #349: 652721468Case #350: 89823493Case #351: 798770146Case #352: 23943493Case #353: 657247993Case #354: 2Case #355: 462606752Case #356: 754834868Case #357: 0Case #358: 768347917Case #359: 574849159Case #360: 493991910Case #361: 482235403Case #362: 733647085Case #363: 464886294Case #364: 367230392Case #365: 963536462Case #366: 30896960Case #367: 488115680Case #368: 100025063Case #369: 85505805Case #370: 257505032Case #371: 0Case #372: 112810844Case #373: 204386229Case #374: 650456788Case #375: 886880859Case #376: 621284699Case #377: 123981371Case #378: 628156118Case #379: 313050211Case #380: 0Case #381: 561409061Case #382: 884917931Case #383: 138761374Case #384: 495214827Case #385: 0Case #386: 339710566Case #387: 0Case #388: 31526131Case #389: 177960879Case #390: 0Case #391: 373755965Case #392: 554616850Case #393: 372101523Case #394: 0Case #395: 328174392Case #396: 75452867Case #397: 389723110Case #398: 903406573Case #399: 0Case #400: 995181912Case #401: 177486120Case #402: 0Case #403: 875614446Case #404: 0Case #405: 525150282Case #406: 146534421Case #407: 195538475Case #408: 0Case #409: 777208150Case #410: 328256885Case #411: 383680583Case #412: 175838002Case #413: 429238401Case #414: 61585557Case #415: 258463037Case #416: 641795625Case #417: 583816961Case #418: 358121410Case #419: 23420325Case #420: 2Case #421: 19627707Case #422: 0Case #423: 190132485Case #424: 269509236Case #425: 810480317Case #426: 325938253Case #427: 941451213Case #428: 800680581Case #429: 487252635Case #430: 954711152Case #431: 429001925Case #432: 946913566Case #433: 721106388Case #434: 0Case #435: 954587861Case #436: 801862520Case #437: 276372696Case #438: 0Case #439: 0Case #440: 26220406Case #441: 20177848Case #442: 755314322Case #443: 83217457Case #444: 413683734Case #445: 694150498Case #446: 563690043Case #447: 201547053Case #448: 174915366Case #449: 556096921Case #450: 780300334Case #451: 713858371Case #452: 983021025Case #453: 931983039Case #454: 589408389Case #455: 586961042Case #456: 406189696Case #457: 140574466Case #458: 857491232Case #459: 240667579Case #460: 515774682Case #461: 493891161Case #462: 0Case #463: 969535949Case #464: 840879442Case #465: 441075634Case #466: 46805019Case #467: 0Case #468: 241109538Case #469: 527338767Case #470: 276060246Case #471: 196235025Case #472: 388970413Case #473: 992000839Case #474: 439128316Case #475: 0Case #476: 674627147Case #477: 83147549Case #478: 648051263Case #479: 117467131Case #480: 186885847Case #481: 993453521Case #482: 0Case #483: 421710031Case #484: 141152733Case #485: 0Case #486: 0Case #487: 638818706Case #488: 278540304Case #489: 196194859Case #490: 0Case #491: 469271047Case #492: 507731637Case #493: 886093544Case #494: 537120297Case #495: 837983363Case #496: 457950493Case #497: 0Case #498: 308666732Case #499: 133051573Case #500: 845916814Case #501: 556775891Case #502: 0Case #503: 194973586Case #504: 847611749Case #505: 0Case #506: 442361677Case #507: 765950527Case #508: 424875258Case #509: 974163489Case #510: 0Case #511: 552423844Case #512: 805129686Case #513: 44854795Case #514: 894969538Case #515: 0Case #516: 377676609Case #517: 947305236Case #518: 0Case #519: 149366674Case #520: 340647779Case #521: 633524706Case #522: 0Case #523: 329047588Case #524: 904019457Case #525: 477069465Case #526: 772725243Case #527: 192943800Case #528: 832901080Case #529: 464479569123456789101112131415161718192021222324252627282930313233343536373839404142434445<p>The night sky can be modeled as an infinite 2D plane. There are <strong>N</strong> stars at distinct positions on this plane, the <strong>i</strong>th of which is at coordinates (<strong>X<sub>i</sub></strong>, <strong>Y<sub>i</sub></strong>).</p>
<p>A boomerang constellation is a pair of distinct equal-length line segments which share a single endpoint, such that both endpoints of each segment coincide with a star's location.</p>
<p>Two boomerang constellations are distinct if they're not made up of the same unordered pair of line segments. How many distinct boomerang constellations can you spot?</p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of nights on which you look out at the sky.For each night, there is first a line containing the integer <strong>N</strong>. Then, <strong>N</strong>lines follow, the <strong>i</strong>th of which contains the space-separated integers <strong>X<sub>i</sub></strong> and <strong>Y<sub>i</sub></strong>.</p>
<h3>Output</h3><p>For the <strong>i</strong>th night, print a line containing "Case #<strong>i</strong>: " followed bythe number of boomerang constellations in the night sky.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 50 <br />1 ≤ <strong>N</strong> ≤ 2,000 <br />-10,000 ≤ <strong>X<sub>i</sub></strong>, <strong>Y<sub>i</sub></strong> ≤ 10,000 <br /></p>
<h3>Explanation of Sample</h3><p>On the first night, every pair of stars is a unique distance apart, so there are no boomerang constellations. On the second night, there are 4 boomerang constellations. One of them consists of the line segments (0,0)-(0,2) and (0,2)-(0,4).</p>
12345678910111213141516171819202122232425262728293031323334353637The night sky can be modeled as an infinite 2D plane. There are **N** stars atdistinct positions on this plane, the **i**th of which is at coordinates(**Xi**, **Yi**).
A boomerang constellation is a pair of distinct equal-length line segmentswhich share a single endpoint, such that both endpoints of each segmentcoincide with a star's location.
Two boomerang constellations are distinct if they're not made up of the sameunordered pair of line segments. How many distinct boomerang constellationscan you spot?
### Input
Input begins with an integer **T**, the number of nights on which you look outat the sky. For each night, there is first a line containing the integer**N**. Then, **N** lines follow, the **i**th of which contains the space-separated integers **Xi** and **Yi**.
### Output
For the **i**th night, print a line containing "Case #**i**: " followed by thenumber of boomerang constellations in the night sky.
### Constraints
1 ≤ **T** ≤ 50 1 ≤ **N** ≤ 2,000 -10,000 ≤ **Xi**, **Yi** ≤ 10,000
### Explanation of Sample
On the first night, every pair of stars is a unique distance apart, so thereare no boomerang constellations. On the second night, there are 4 boomerangconstellations. One of them consists of the line segments (0,0)-(0,2) and(0,2)-(0,4).
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475Case #1: 0Case #2: 4Case #3: 4Case #4: 3Case #5: 12Case #6: 8293552Case #7: 7734388Case #8: 7156263Case #9: 6744808Case #10: 6234753Case #11: 5844124Case #12: 6Case #13: 0Case #14: 81Case #15: 58Case #16: 197Case #17: 2712Case #18: 19Case #19: 1Case #20: 662Case #21: 28Case #22: 92Case #23: 0Case #24: 94Case #25: 53Case #26: 463Case #27: 210Case #28: 283Case #29: 0Case #30: 0Case #31: 105Case #32: 1396Case #33: 126Case #34: 98Case #35: 31Case #36: 225Case #37: 872Case #38: 60Case #39: 362Case #40: 10Case #41: 1Case #42: 11Case #43: 3009Case #44: 132Case #45: 2808Case #46: 163Case #47: 119Case #48: 107Case #49: 1730Case #50: 30Case #51: 284Case #52: 62Case #53: 0Case #54: 1Case #55: 16Case #56: 143Case #57: 0Case #58: 405452Case #59: 57Case #60: 1029Case #61: 3Case #62: 17Case #63: 0Case #64: 13Case #65: 50Case #66: 146Case #67: 228Case #68: 33Case #69: 5Case #70: 17Case #71: 132Case #72: 0Case #73: 203Case #74: 35Case #75: 1681234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162<p>A top-secret algorithmic research facility has decided to up its security by hiring guards to keep watch over the premises. After all, they don't want anyone sneaking in and learning the answers to questions such as "does P = NP?" and "what are the solutions to the 2016 Facebook Hacker Cup problems?".</p>
<p>When viewed from above, the facility can be modeled as a grid <strong>G</strong> with 2 rows and <strong>N</strong> columns. The <strong>j</strong>th cell in the <strong>i</strong>th row is either empty (represented by <strong>G<sub>i,j</sub></strong> = ".") or occupied by a building (<strong>G<sub>i,j</sub></strong> = "X"), and the grid includes at least one empty cell.</p>
<p>Guards may be potentially stationed in any of the empty cells. A guard can see not only their own cell, but also all contiguous empty cells in each of the 4 compass directions (up, down, left, and right) until the edge of the grid or a building. For example, in the grid below, the guard ("G") can see every cell marked with an asterisk ("*"):</p>
<pre>.*.X.X..*G*****X</pre>
<p>What is the minimum number of guards required such that every empty cell in the grid can be seen by at least one of them?</p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of facilities that need guarding.For each facility, there is first a line containing the integer <strong>N</strong>. The next line contains the grid cells<strong>G<sub>1,1</sub></strong> to <strong>G<sub>1,N</sub></strong> in order. The third line contains the grid cells<strong>G<sub>2,1</sub></strong> to <strong>G<sub>2,N</sub></strong> in order.</p>
<h3>Output</h3><p>For the <strong>i</strong>th facility, print a line containing "Case #<strong>i</strong>: " followed bythe number of guards required to guard the facility.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 200 <br />1 ≤ <strong>N</strong> ≤ 1,000 <br /></p>
<h3>Explanation of Sample</h3><p>In the first case, one solution is to place three guards as follows:</p>
<pre>.G.X.XG.....G..X</pre>
12345678910111213141516171819202122232425262728293031323334353637383940414243444546A top-secret algorithmic research facility has decided to up its security byhiring guards to keep watch over the premises. After all, they don't wantanyone sneaking in and learning the answers to questions such as "does P =NP?" and "what are the solutions to the 2016 Facebook Hacker Cup problems?".
When viewed from above, the facility can be modeled as a grid **G** with 2rows and **N** columns. The **j**th cell in the **i**th row is either empty(represented by **Gi,j** = ".") or occupied by a building (**Gi,j** = "X"),and the grid includes at least one empty cell.
Guards may be potentially stationed in any of the empty cells. A guard can seenot only their own cell, but also all contiguous empty cells in each of the 4compass directions (up, down, left, and right) until the edge of the grid or abuilding. For example, in the grid below, the guard ("G") can see every cellmarked with an asterisk ("*"):
.*.X.X.. *G*****X
What is the minimum number of guards required such that every empty cell inthe grid can be seen by at least one of them?
### Input
Input begins with an integer **T**, the number of facilities that needguarding. For each facility, there is first a line containing the integer**N**. The next line contains the grid cells **G1,1** to **G1,N** in order.The third line contains the grid cells **G2,1** to **G2,N** in order.
### Output
For the **i**th facility, print a line containing "Case #**i**: " followed bythe number of guards required to guard the facility.
### Constraints
1 ≤ **T** ≤ 200 1 ≤ **N** ≤ 1,000
### Explanation of Sample
In the first case, one solution is to place three guards as follows:
.G.X.XG. ....G..X
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307Case #1: 3Case #2: 3Case #3: 2Case #4: 5Case #5: 6Case #6: 1Case #7: 1Case #8: 411Case #9: 360Case #10: 345Case #11: 315Case #12: 67Case #13: 223Case #14: 134Case #15: 174Case #16: 325Case #17: 98Case #18: 308Case #19: 236Case #20: 220Case #21: 70Case #22: 241Case #23: 161Case #24: 128Case #25: 20Case #26: 147Case #27: 376Case #28: 240Case #29: 191Case #30: 132Case #31: 267Case #32: 10Case #33: 237Case #34: 338Case #35: 238Case #36: 213Case #37: 315Case #38: 187Case #39: 325Case #40: 146Case #41: 103Case #42: 237Case #43: 146Case #44: 129Case #45: 173Case #46: 252Case #47: 25Case #48: 355Case #49: 244Case #50: 270Case #51: 285Case #52: 10Case #53: 283Case #54: 203Case #55: 107Case #56: 262Case #57: 319Case #58: 213Case #59: 380Case #60: 177Case #61: 282Case #62: 99Case #63: 304Case #64: 285Case #65: 116Case #66: 246Case #67: 103Case #68: 120Case #69: 164Case #70: 351Case #71: 185Case #72: 61Case #73: 254Case #74: 314Case #75: 249Case #76: 231Case #77: 147Case #78: 375Case #79: 304Case #80: 62Case #81: 320Case #82: 273Case #83: 282Case #84: 201Case #85: 207Case #86: 406Case #87: 284Case #88: 268Case #89: 150Case #90: 250Case #91: 179Case #92: 197Case #93: 264Case #94: 374Case #95: 172Case #96: 74Case #97: 208Case #98: 277Case #99: 58Case #100: 146Case #101: 217Case #102: 58Case #103: 203Case #104: 68Case #105: 286Case #106: 350Case #107: 118Case #108: 151Case #109: 249Case #110: 402Case #111: 81Case #112: 382Case #113: 239Case #114: 366Case #115: 250Case #116: 286Case #117: 318Case #118: 137Case #119: 320Case #120: 151Case #121: 284Case #122: 176Case #123: 196Case #124: 182Case #125: 107Case #126: 220Case #127: 253Case #128: 215Case #129: 260Case #130: 290Case #131: 202Case #132: 217Case #133: 136Case #134: 258Case #135: 220Case #136: 55Case #137: 228Case #138: 349Case #139: 126Case #140: 352Case #141: 373Case #142: 35Case #143: 108Case #144: 166Case #145: 234Case #146: 220Case #147: 126Case #148: 392Case #149: 312Case #150: 211Case #151: 127Case #152: 144Case #153: 235Case #154: 213Case #155: 379Case #156: 189Case #157: 388Case #158: 247Case #159: 85Case #160: 209Case #161: 201Case #162: 255Case #163: 258Case #164: 311Case #165: 123Case #166: 253Case #167: 72Case #168: 223Case #169: 233Case #170: 161Case #171: 259Case #172: 265Case #173: 294Case #174: 310Case #175: 180Case #176: 173Case #177: 233Case #178: 333Case #179: 201Case #180: 236Case #181: 114Case #182: 228Case #183: 380Case #184: 143Case #185: 368Case #186: 231Case #187: 313Case #188: 246Case #189: 362Case #190: 111Case #191: 297Case #192: 212Case #193: 99Case #194: 250Case #195: 225Case #196: 361Case #197: 190Case #198: 163Case #199: 78Case #200: 10Case #201: 208Case #202: 275Case #203: 139Case #204: 193Case #205: 269Case #206: 77Case #207: 258Case #208: 261Case #209: 234Case #210: 391Case #211: 262Case #212: 319Case #213: 280Case #214: 214Case #215: 222Case #216: 311Case #217: 166Case #218: 234Case #219: 370Case #220: 289Case #221: 236Case #222: 236Case #223: 279Case #224: 186Case #225: 77Case #226: 286Case #227: 239Case #228: 196Case #229: 58Case #230: 306Case #231: 226Case #232: 346Case #233: 194Case #234: 65Case #235: 110Case #236: 115Case #237: 327Case #238: 271Case #239: 181Case #240: 213Case #241: 245Case #242: 254Case #243: 133Case #244: 286Case #245: 102Case #246: 109Case #247: 129Case #248: 185Case #249: 340Case #250: 248Case #251: 369Case #252: 232Case #253: 103Case #254: 250Case #255: 218Case #256: 321Case #257: 120Case #258: 338Case #259: 330Case #260: 238Case #261: 128Case #262: 301Case #263: 193Case #264: 190Case #265: 220Case #266: 213Case #267: 127Case #268: 201Case #269: 239Case #270: 55Case #271: 112Case #272: 90Case #273: 147Case #274: 163Case #275: 378Case #276: 255Case #277: 296Case #278: 73Case #279: 335Case #280: 7Case #281: 357Case #282: 290Case #283: 175Case #284: 370Case #285: 116Case #286: 136Case #287: 396Case #288: 269Case #289: 410Case #290: 86Case #291: 318Case #292: 289Case #293: 222Case #294: 169Case #295: 284Case #296: 231Case #297: 377Case #298: 274Case #299: 231Case #300: 13Case #301: 216Case #302: 182Case #303: 170Case #304: 278Case #305: 144Case #306: 109Case #307: 3051234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253<p>You've managed to become a contestant on the hottest new game show, The Price is Correct!</p>
<p>After asking you to come on down to the stage, the show's host presents you with a row of <strong>N</strong> closed boxes, numbered from 1 to <strong>N</strong> in order, each containing a secret positive integer. A curtain opens to reveal a shiny, new tricycle — you recognize it as an expensive, top-of-the-line model.</p>
<p>The host then proceeds to explain the rules: you must select a contiguous sequence of the boxes (boxes a..b, for some 1 ≤ a ≤ b ≤ <strong>N</strong>). Your chosen boxes will then be opened, and if the sum of the numbers inside is no greater than the price of the tricycle, you win it!</p>
<p>You'd sure like to win that tricycle. Fortunately, not only are you aware that its price is exactly <strong>P</strong>, but you've paid off the host to let you in on the contents of the boxes! You know that each box <strong>i</strong> contains the number <strong>B<sub>i</sub></strong>.</p>
<p>How many different sequences of boxes can you choose such that you win the tricycle? Each sequence is defined by its starting and ending box indices (a and b).</p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of times you appear on The Price is Correct.For each show, there is first a line containing the space-separated integers <strong>N</strong> and <strong>P</strong>. The next line contains <strong>N</strong> space-separated integers, <strong>B<sub>1</sub></strong> through <strong>B<sub>N</sub></strong> in order.</p>
<h3>Output</h3><p>For the <strong>i</strong>th show, print a line containing "Case #<strong>i</strong>: " followed bythe number of box sequences that will win you the tricycle.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 40 <br />1 ≤ <strong>N</strong> ≤ 100,000 <br />1 ≤ <strong>P</strong> ≤ 1,000,000,000 <br />1 ≤ <strong>B<sub>i</sub></strong> ≤ 1,000,000,000 <br /></p>
<h3>Explanation of Sample</h3><p>In the first case no sequence adds up to more than 50, so all 10 sequences are winners. In the fourth case, you can select any single box, or the sequences (1, 2), (1, 3), and (2, 3), for 9 total winning sequences.</p>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647You've managed to become a contestant on the hottest new game show, The Priceis Correct!
After asking you to come on down to the stage, the show's host presents youwith a row of **N** closed boxes, numbered from 1 to **N** in order, eachcontaining a secret positive integer. A curtain opens to reveal a shiny, newtricycle — you recognize it as an expensive, top-of-the-line model.
The host then proceeds to explain the rules: you must select a contiguoussequence of the boxes (boxes a..b, for some 1 ≤ a ≤ b ≤ **N**). Your chosenboxes will then be opened, and if the sum of the numbers inside is no greaterthan the price of the tricycle, you win it!
You'd sure like to win that tricycle. Fortunately, not only are you aware thatits price is exactly **P**, but you've paid off the host to let you in on thecontents of the boxes! You know that each box **i** contains the number**Bi**.
How many different sequences of boxes can you choose such that you win thetricycle? Each sequence is defined by its starting and ending box indices (aand b).
### Input
Input begins with an integer **T**, the number of times you appear on ThePrice is Correct. For each show, there is first a line containing the space-separated integers **N** and **P**. The next line contains **N** space-separated integers, **B1** through **BN** in order.
### Output
For the **i**th show, print a line containing "Case #**i**: " followed by thenumber of box sequences that will win you the tricycle.
### Constraints
1 ≤ **T** ≤ 40 1 ≤ **N** ≤ 100,000 1 ≤ **P** ≤ 1,000,000,000 1 ≤ **Bi** ≤ 1,000,000,000
### Explanation of Sample
In the first case no sequence adds up to more than 50, so all 10 sequences arewinners. In the fourth case, you can select any single box, or the sequences(1, 2), (1, 3), and (2, 3), for 9 total winning sequences.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455Case #1: 10Case #2: 0Case #3: 3Case #4: 9Case #5: 18Case #6: 5000050000Case #7: 4447875291Case #8: 4444789339Case #9: 4442082364Case #10: 999955Case #11: 0Case #12: 1Case #13: 246753Case #14: 193131Case #15: 286146Case #16: 176715Case #17: 348195Case #18: 179700Case #19: 427350Case #20: 365940Case #21: 250278Case #22: 241860Case #23: 183315Case #24: 261003Case #25: 360825Case #26: 154290Case #27: 241860Case #28: 203203Case #29: 306153Case #30: 141778Case #31: 170820Case #32: 243951Case #33: 305371Case #34: 411778Case #35: 404550Case #36: 140185Case #37: 376278Case #38: 240471Case #39: 378885Case #40: 125250Case #41: 429201Case #42: 187578Case #43: 246753Case #44: 190653Case #45: 269011Case #46: 271216Case #47: 409060Case #48: 158203Case #49: 287661Case #50: 431056Case #51: 368511Case #52: 284635Case #53: 137026Case #54: 139656Case #55: 22078012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667<p>You have a list of <strong>N</strong> distinct words, consisting of only lowercase letters. You'd like to print any <strong>K</strong> words from this list, one per page, in any order.</p>
<p>You will accomplish this using a very basic text editor. It supports 3 types of operations: typing a letter, deleting the previous letter, and printing the current document. Note that it does not allow the cursor to be moved! This means that the first operation may only add a letter to the end of the document, and the second may only delete the last letter (if any). Due to issues with memory leakage, you also need to remember to leave the document completely empty after you've printed your <strong>K</strong> words!</p>
<p>What's the minimum number of operations required to get the job done?</p>
<p>As an example, let's say that you want to print 3 of the following 5 words:</p>
<pre>ahairboxawesomehail</pre>
<p>One optimal sequence of 15 operations is as follows:</p>
<p><ul><li> - type 'h', 'a', 'i', and 'r' (document = 'hair')<li> - print<li> - backspace (document = 'hai')<li> - type 'l' (document = 'hail')<li> - print<li> - backspace 4 times (document = empty)<li> - type 'a' (document = 'a')<li> - print<li> - backspace (document = empty)</ul></p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of sets of words you want to print.For each set, there is first a line containing the space-separated integers <strong>N</strong> and <strong>K</strong>. The next <strong>N</strong> lines contain the set of words, one per line.</p>
<h3>Output</h3><p>For the <strong>i</strong>th set of words, print a line containing "Case #<strong>i</strong>: " followed bythe minimum number of operations required to print <strong>K</strong> of the words and then leave the document empty.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 100 <br />1 ≤ <strong>K</strong> ≤ <strong>N</strong> ≤ 300 <br />The total length of all <strong>N</strong> words in each set will be at most 100,000 characters.<br /></p>
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354You have a list of **N** distinct words, consisting of only lowercase letters.You'd like to print any **K** words from this list, one per page, in anyorder.
You will accomplish this using a very basic text editor. It supports 3 typesof operations: typing a letter, deleting the previous letter, and printing thecurrent document. Note that it does not allow the cursor to be moved! Thismeans that the first operation may only add a letter to the end of thedocument, and the second may only delete the last letter (if any). Due toissues with memory leakage, you also need to remember to leave the documentcompletely empty after you've printed your **K** words!
What's the minimum number of operations required to get the job done?
As an example, let's say that you want to print 3 of the following 5 words:
a hair box awesome hail
One optimal sequence of 15 operations is as follows:
* \- type 'h', 'a', 'i', and 'r' (document = 'hair') * \- print * \- backspace (document = 'hai') * \- type 'l' (document = 'hail') * \- print * \- backspace 4 times (document = empty) * \- type 'a' (document = 'a') * \- print * \- backspace (document = empty)
### Input
Input begins with an integer **T**, the number of sets of words you want toprint. For each set, there is first a line containing the space-separatedintegers **N** and **K**. The next **N** lines contain the set of words, oneper line.
### Output
For the **i**th set of words, print a line containing "Case #**i**: " followedby the minimum number of operations required to print **K** of the words andthen leave the document empty.
### Constraints
1 ≤ **T** ≤ 100 1 ≤ **K** ≤ **N** ≤ 300 The total length of all **N** words in each set will be at most 100,000characters.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305Case #1: 9
Case #2: 9
Case #3: 11
Case #4: 15
Case #5: 26
Case #6: 8812
Case #7: 8774
Case #8: 8756
Case #9: 27491
Case #10: 36411
Case #11: 15019
Case #12: 14591
Case #13: 5427
Case #14: 3944
Case #15: 9756
Case #16: 605
Case #17: 3025
Case #18: 5849
Case #19: 3192
Case #20: 13078
Case #21: 6533
Case #22: 16314
Case #23: 9331
Case #24: 189
Case #25: 920
Case #26: 16748
Case #27: 24532
Case #28: 91
Case #29: 13890
Case #30: 4846
Case #31: 3371
Case #32: 6489
Case #33: 8552
Case #34: 1818
Case #35: 12969
Case #36: 149
Case #37: 60
Case #38: 12903
Case #39: 10685
Case #40: 9150
Case #41: 3262
Case #42: 1595
Case #43: 13824
Case #44: 81
Case #45: 1071
Case #46: 1012
Case #47: 502
Case #48: 8756
Case #49: 497
Case #50: 512
Case #51: 2543
Case #52: 416
Case #53: 7446
Case #54: 6005
Case #55: 15052
Case #56: 19605
Case #57: 1252
Case #58: 8206
Case #59: 25244
Case #60: 1124
Case #61: 361
Case #62: 8077
Case #63: 1681
Case #64: 6060
Case #65: 1701
Case #66: 11117
Case #67: 2693
Case #68: 7593
Case #69: 9253
Case #70: 177
Case #71: 2861
Case #72: 10045
Case #73: 2511
Case #74: 2761
Case #75: 1723
Case #76: 482
Case #77: 11676
Case #78: 16966
Case #79: 4015
Case #80: 4553
Case #81: 713
Case #82: 10694
Case #83: 12851
Case #84: 3949
Case #85: 19783
Case #86: 67
Case #87: 22149
Case #88: 15807
Case #89: 514
Case #90: 17968
Case #91: 3162
Case #92: 312
Case #93: 1229
Case #94: 1075
Case #95: 3481
Case #96: 4546
Case #97: 213
Case #98: 7898
Case #99: 78
Case #100: 2891
Case #101: 2012
Case #102: 1908
Case #103: 2070
Case #104: 11511
Case #105: 585
Case #106: 3812
Case #107: 11050
Case #108: 1057
Case #109: 2438
Case #110: 230
Case #111: 14344
Case #112: 24529
Case #113: 8410
Case #114: 1661
Case #115: 4128
Case #116: 15214
Case #117: 4299
Case #118: 983
Case #119: 21284
Case #120: 8296
Case #121: 1771
Case #122: 9697
Case #123: 1059
Case #124: 4413
Case #125: 5259
Case #126: 3061
Case #127: 69
Case #128: 44
Case #129: 3428
Case #130: 3857
Case #131: 1439
Case #132: 10028
Case #133: 28577
Case #134: 979
Case #135: 116
Case #136: 628
Case #137: 405
Case #138: 6963
Case #139: 21
Case #140: 4596
Case #141: 4237
Case #142: 12634
Case #143: 16377
Case #144: 12038
Case #145: 109
Case #146: 52
Case #147: 1596
Case #148: 57
Case #149: 1249
Case #150: 13407
Case #151: 577
Case #152: 9905
Case #153: 19302
Case #154: 1695
Case #155: 1378
Case #156: 10398
Case #157: 109
Case #158: 21556
Case #159: 7114
Case #160: 19997
Case #161: 3106
Case #162: 1231
Case #163: 1902
Case #164: 29865
Case #165: 201
Case #166: 928
Case #167: 6361
Case #168: 20818
Case #169: 591
Case #170: 1729
Case #171: 6985
Case #172: 14782
Case #173: 3282
Case #174: 3935
Case #175: 6762
Case #176: 6063
Case #177: 856
Case #178: 5034
Case #179: 573
Case #180: 6627
Case #181: 6669
Case #182: 2433
Case #183: 211
Case #184: 589
Case #185: 376
Case #186: 11340
Case #187: 1972
Case #188: 4038
Case #189: 12784
Case #190: 2861
Case #191: 14958
Case #192: 4865
Case #193: 857
Case #194: 4837
Case #195: 10637
Case #196: 411
Case #197: 8735
Case #198: 5426
Case #199: 2115
Case #200: 5699
Case #201: 335
Case #202: 20860
Case #203: 3803
Case #204: 20437
Case #205: 29841
Case #206: 4470
Case #207: 194
Case #208: 11023
Case #209: 4031
Case #210: 10424
Case #211: 6847
Case #212: 473
Case #213: 6304
Case #214: 1201
Case #215: 629
Case #216: 8371
Case #217: 3149
Case #218: 84
Case #219: 20585
Case #220: 2301
Case #221: 17243
Case #222: 1673
Case #223: 1920
Case #224: 1960
Case #225: 1582
Case #226: 2987
Case #227: 5288
Case #228: 13014
Case #229: 911
Case #230: 854
Case #231: 832
Case #232: 2482
Case #233: 1828
Case #234: 13224
Case #235: 21
Case #236: 712
Case #237: 14188
Case #238: 7393
Case #239: 11388
Case #240: 7482
Case #241: 2847
Case #242: 4123
Case #243: 14069
Case #244: 1009
Case #245: 25057
Case #246: 1059
Case #247: 12862
Case #248: 5596
Case #249: 6062
Case #250: 1956
Case #251: 21
Case #252: 2523
Case #253: 361
Case #254: 233
Case #255: 3824
Case #256: 2953
Case #257: 13889
Case #258: 3942
Case #259: 6759
Case #260: 1545
Case #261: 5651
Case #262: 4665
Case #263: 31
Case #264: 853
Case #265: 5826
Case #266: 20405
Case #267: 7706
Case #268: 26556
Case #269: 37
Case #270: 143
Case #271: 3938
Case #272: 977
Case #273: 81
Case #274: 9834
Case #275: 11271
Case #276: 2309
Case #277: 1945
Case #278: 10732
Case #279: 9839
Case #280: 389
Case #281: 12091
Case #282: 4845
Case #283: 2144
Case #284: 439
Case #285: 13056
Case #286: 10592
Case #287: 2083
Case #288: 5505
Case #289: 9785
Case #290: 289
Case #291: 161
Case #292: 1736
Case #293: 5432
Case #294: 2745
Case #295: 9092
Case #296: 5091
Case #297: 1158
Case #298: 18546
Case #299: 411
Case #300: 1042
Case #301: 4056
Case #302: 2093
Case #303: 6747
Case #304: 285
Case #305: 441234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677<p>This weekend, the long-awaited BIT (Boomerang Invitational Tournament) will be taking place! <strong>N</strong> of the finest boomerangists will be competing in a randomly-seeded single-elimination bracket.</p>
<p>For those unfamiliar with this tournament format, the process can be modelled as follows:</p>
<p><ol><li> The <strong>N</strong> competitors are arranged in a queue (an ordered list), in some order </li><li> If the queue currently contains only 1 competitor, the tournament ends with them as the champion </li><li> Otherwise, the first 2 competitors in the front of the queue are removed, and they play a match against one another </li><li> The winner of that match is re-inserted into the queue, at the back </li><li> Repeat from step 2 </li></ol></p>
<p>The one-on-one matches in this tournament are, of course, boomerang duels to the death. If the <strong>i</strong>th and <strong>j</strong>th competitors face off against one another, the <strong>i</strong>th competitor will win if <strong>W<sub>i,j</sub></strong> = 1. Otherwise, if <strong>W<sub>i,j</sub></strong> = 0, the <strong>j</strong>th competitor will win. Note that, for all (1 ≤ <strong>i</strong>, <strong>j</strong> ≤ <strong>N</strong>), <strong>W<sub>i,j</sub></strong> = 0 or 1, and <strong>W<sub>i,i</sub></strong> = 0 (no one will play against themselves anyway), and <strong>W<sub>i,j</sub></strong> ≠ <strong>W<sub>j,i</sub></strong> (if <strong>i</strong> ≠ <strong>j</strong>). Those are the only constraints. It's possible that, for example, competitor A can beat B, B can beat C, and C can beat A.</p>
<p>Once the tournament is over, each boomerangist is given a placing (even if they didn't survive the competition). A given competitor <strong>c</strong>'s placing is an integer one greater than the number of competitors who won strictly more matches than <strong>c</strong> did.</p>
<p>For each boomerangist, you'd like to know both the best (smallest) and the worst (largest) placing they could possibly end up with, given that the initial ordering of the competitors (in step 1 of the tournament) is unknown.</p>
<h3>Input</h3><p>Input begins with an integer <strong>T</strong>, the number of tournaments.For each tournament, there is first a line containing the integer <strong>N</strong>.Then follow <strong>N</strong> lines, the <strong>i</strong>th of which contains the space-separated integers<strong>W<sub>i,1</sub></strong> through <strong>W<sub>i,N</sub></strong>.</p>
<h3>Output</h3><p>For the <strong>i</strong>th tournament, print a line containing "Case #<strong>i</strong>: " followed by<strong>N</strong> lines that each contain two space-separated integers. The first integer on the <strong>i</strong>th lineshould be the best possible placing for the <strong>i</strong>th competitor, and the second should be the worst possible placing.</p>
<h3>Constraints</h3><p>1 ≤ <strong>T</strong> ≤ 250 <br /><strong>N</strong> = 2<sup><strong>K</strong></sup> where <strong>K</strong> is an integer and 0 ≤ <strong>K</strong> ≤ 4 <br /></p>
<h3>Explanation of Sample</h3><p>In the second tournament, the first competitor will always beat the second competitor, so the first competitor will finish in 1st place, and the other in 2nd place.
In the third tournament, the first competitor never loses, so they will finish in 1st place. The fourth competitor never wins, so they will finish tied for 3rd place withthe other competitor who loses their initial match.
The other two competitors will either lose their first match (if initially paired with the first competitor) or their second match (if initially paired with the fourth competitor),so they can each finish in 2nd place, or tied for 3rd place.</p>
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395305
1
0
2
0 1
0 0
4
0 1 1 1
0 0 1 1
0 0 0 1
0 0 0 0
4
0 0 0 0
1 0 0 1
1 1 0 0
1 0 1 0
8
0 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0
1 0 0 0 0 0 0 0
1 1 1 0 0 1 1 0
1 1 1 1 0 1 0 1
1 1 1 0 0 0 0 1
1 1 1 0 1 1 0 1
1 1 1 1 0 0 0 0
16
0 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1
0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 1
0 1 0 0 0 1 1 1 0 0 0 0 1 1 0 1
0 1 1 0 0 0 1 1 1 1 1 0 1 1 1 0
0 1 1 1 0 1 1 0 1 0 1 0 1 0 0 0
0 1 0 1 0 0 0 1 1 0 0 1 0 1 1 1
0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 0
1 0 0 0 1 0 0 0 0 0 1 1 1 0 0 0
1 1 1 0 0 0 0 1 0 0 0 1 1 1 1 0
0 1 1 0 1 1 0 1 1 0 1 0 0 1 0 0
1 0 1 0 0 1 0 0 1 0 0 0 0 1 1 0
0 0 1 1 1 0 1 0 0 1 1 0 0 0 0 1
0 1 0 0 0 1 1 0 0 1 1 1 0 0 0 1
0 1 0 0 1 0 0 1 0 0 0 1 1 0 0 1
0 0 1 0 1 0 0 1 0 1 0 1 1 1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 1 0 0 0 0 1 1 1 0
0 0 1 1 0 0 0 0 1 0 0 1 1 0 1 0
0 0 1 0 1 0 1 0 0 0 1 1 1 0 0 0
1 1 1 1 0 1 0 1 0 0 0 1 1 0 0 0
1 1 0 0 1 1 1 1 1 0 1 1 1 1 1 1
0 0 1 0 1 1 1 0 1 0 0 1 1 0 1 1
1 0 1 1 0 1 0 0 0 0 0 0 1 0 1 0
0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 1 1 1 0 1 1 1 0 0 0
0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 1
1 0 0 0 0 1 1 1 1 0 0 1 1 1 0 01234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162This weekend, the long-awaited BIT (Boomerang Invitational Tournament) will betaking place! **N** of the finest boomerangists will be competing in arandomly-seeded single-elimination bracket.
For those unfamiliar with this tournament format, the process can be modelledas follows:
1. The **N** competitors are arranged in a queue (an ordered list), in some order 2. If the queue currently contains only 1 competitor, the tournament ends with them as the champion 3. Otherwise, the first 2 competitors in the front of the queue are removed, and they play a match against one another 4. The winner of that match is re-inserted into the queue, at the back 5. Repeat from step 2
The one-on-one matches in this tournament are, of course, boomerang duels tothe death. If the **i**th and **j**th competitors face off against oneanother, the **i**th competitor will win if **Wi,j** = 1. Otherwise, if**Wi,j** = 0, the **j**th competitor will win. Note that, for all (1 ≤ **i**,**j** ≤ **N**), **Wi,j** = 0 or 1, and **Wi,i** = 0 (no one will play againstthemselves anyway), and **Wi,j** ≠ **Wj,i** (if **i** ≠ **j**). Those are theonly constraints. It's possible that, for example, competitor A can beat B, Bcan beat C, and C can beat A.
Once the tournament is over, each boomerangist is given a placing (even ifthey didn't survive the competition). A given competitor **c**'s placing is aninteger one greater than the number of competitors who won strictly morematches than **c** did.
For each boomerangist, you'd like to know both the best (smallest) and theworst (largest) placing they could possibly end up with, given that theinitial ordering of the competitors (in step 1 of the tournament) is unknown.
### Input
Input begins with an integer **T**, the number of tournaments. For eachtournament, there is first a line containing the integer **N**. Then follow**N** lines, the **i**th of which contains the space-separated integers**Wi,1** through **Wi,N**.
### Output
For the **i**th tournament, print a line containing "Case #**i**: " followedby **N** lines that each contain two space-separated integers. The firstinteger on the **i**th line should be the best possible placing for the**i**th competitor, and the second should be the worst possible placing.
### Constraints
1 ≤ **T** ≤ 250 **N** = 2**K** where **K** is an integer and 0 ≤ **K** ≤ 4
### Explanation of Sample
In the second tournament, the first competitor will always beat the secondcompetitor, so the first competitor will finish in 1st place, and the other in2nd place. In the third tournament, the first competitor never loses, so theywill finish in 1st place. The fourth competitor never wins, so they willfinish tied for 3rd place with the other competitor who loses their initialmatch. The other two competitors will either lose their first match (ifinitially paired with the first competitor) or their second match (ifinitially paired with the fourth competitor), so they can each finish in 2ndplace, or tied for 3rd place.
.gitattributes+5
2016/finals/boomerang_crews.cppAdded+143
2016/finals/boomerang_crews.htmlAdded+68
2016/finals/boomerang_crews.inAdded+3
2016/finals/boomerang_crews.mdAdded+52
2016/finals/boomerang_crews.outAdded+75
2016/finals/grundy_graph.cppAdded+202
2016/finals/grundy_graph.htmlAdded+51
2016/finals/grundy_graph.inAdded+3
2016/finals/grundy_graph.mdAdded+48
2016/finals/grundy_graph.outAdded+44
2016/finals/maximinimax_flow.cppAdded+271
2016/finals/maximinimax_flow.htmlAdded+93
2016/finals/maximinimax_flow.inAdded+3
2016/finals/maximinimax_flow.mdAdded+76
2016/finals/maximinimax_flow.outAdded+85
2016/finals/rainbow_string.cppAdded+218
2016/finals/rainbow_string.htmlAdded+74
2016/finals/rainbow_string.inAdded+3
2016/finals/rainbow_string.mdAdded+35
2016/finals/rainbow_string.outAdded+55
2016/finals/rng.cppAdded+200
2016/finals/rng.htmlAdded+66
2016/finals/rng.inAdded+3
2016/finals/rng.mdAdded+66
2016/finals/rng.outAdded+46
2016/finals/snake_and_ladder.cppAdded+178
2016/finals/snake_and_ladder.htmlAdded+48
2016/finals/snake_and_ladder.inAdded
2016/finals/snake_and_ladder.mdAdded+67
2016/finals/snake_and_ladder.outAdded+529
2016/quals/boomerang_constellations.htmlAdded+45
2016/quals/boomerang_constellations.inAdded
2016/quals/boomerang_constellations.mdAdded+37
2016/quals/boomerang_constellations.outAdded+75
2016/quals/high_security.htmlAdded+62
2016/quals/high_security.inAdded
2016/quals/high_security.mdAdded+46
2016/quals/high_security.outAdded+307
2016/quals/price.htmlAdded+53
2016/quals/price.inAdded
2016/quals/price.mdAdded+47
2016/quals/price.outAdded+55
2016/quals/text_editor.htmlAdded+67
2016/quals/text_editor.inAdded
2016/quals/text_editor.mdAdded+54
2016/quals/text_editor.outAdded+305
2016/round1/boomerang_tournament.htmlAdded+77
2016/round1/boomerang_tournament.inAdded+2395
2016/round1/boomerang_tournament.mdAdded+62