The first four questions are simple, and the last one has not been done yet.
The first two questions are too easy to post code.
C. It was actually quite simple, but there was something wrong with it, and then it was hack, because it went to bed after an hour of competition and it was found that it was hack, so I tried to repeat the question and found that question A was still A little frustrated ..
Paste the code.
[Cpp]
Void solveC ()
{
Int n, k;
Cin> n> k;
For (int I = 0; I <n; I ++)
{
Scanf ("% d", & a [I]);
}
Sort (a, a + n );
Int num = 0;
For (int I = 0; I <n; I ++)
{
For (int j = n-i-1; j> = 0; j --)
{
Cout <I + 1;
For (int l = n-1; l> = n-I; l --)
{
Cout <"<a [l];
}
Cout <"" <a [j] <endl;
Num ++;
If (num> = k) break;
}
If (num> = k) break;
}
}
D.
[Cpp]
Struct kdq
{
Int u, v;
Int next;
} Edge [2, 1000005];
Int num = 0;
Int head [100005];
Void insert (int u, int v)
{
Edge [num]. u = u;
Edge [num]. v = v;
Edge [num]. next = head [u];
Head [u] = num ++;
}
Set <int> vv [100005];
Int vis [100005];
Void solveD ()
{
Int n, m;
Cin> n> m;
Memset (head,-1, sizeof (head ));
For (int I = 1; I <= n; I ++)
Scanf ("% d", & a [I]);
While (m --)
{
Int a1, b1;
Scanf ("% d", & a1, & b1 );
Insert (a1, b1 );
Insert (b1, a1 );
}
For (int I = 1; I <= n; I ++)
{
For (int j = head [I]; j! =-1; j = edge [j]. next)
{
Int v = edge [j]. v;
If (a [I]! = A [v]) // you cannot add points of the same color to this set.
Vv [a [I]. insert (a [v]);
}
}
Int ans =-1;
Int color =-1;
For (int I = 1; I <= n; I ++)
{
If (vis [a [I]) continue;
Int kk = vv [a [I]. size ();
If (kk> ans)
{
Ans = kk;
Color = a [I];
}
Else if (kk = ans)
{
If (color> a [I])
Color = a [I];
}
Vis [a [I] = 1;
}
Printf ("% d \ n", color );
}
E.