We want to congratulate you with a happy new school year with this contest. We wish you excellent marks, easy exams and many Accepted in the contests. Let this year bring you many new and interesting knowledge!
Artem Rakhov and Codeforces team
P. S. Note that the round will be held on the Codeforces Format Rules. Read the rules before the competition. Good luck!
Also need this test!
5
-1 -2 -6 -3 -4
Btw, how are you getting the tests?
Or any hints about C?
4
1 2 3 4
??
answers are:
(1)
3
1 2 4
(2)
3
1 3 4
3000
1 2 3 4 5 6...... 3000
;)
the answer is 3001
Try this:
Input:
1
2
Output:
1
My Submission ID is 111986
- p_x>p_z & p_z>p_y (won x and lost to y) => p_x>p_y (y better x)
- p_x<p_z & p_z<p_y (lost to x and won y) => p_x<p_y (x better y)
Otherwise we cannot define outcome and able to output any.Just as SKYDOS 's TopSort.
I did it like
cout<<num1<<" "<<num2<<endl;
but I got P.E. on test 1
#include <iostream>
#include <cstring>
using namespace std;
int games[60][60];
int winsto[60][60];
bool getsToWinTo(int i, int j)
{
for(int ii=1; ii<=60; ii++)
{
if(winsto[i][ii] && winsto[ii][j])
return true;
}
return false;
}
int main()
{
int n;
cin>>n;
int a,b;
memset(games,0,sizeof(games));
int t=n*(n-1);
t/=2;
t--;
//cout<<tope<<endl;
for(int i=0; i<t; i++)
{
cin>>a>>b;
games[a][b]=1;
games[b][a]=1;
winsto[a][b]=1;
}
bool done=false;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
if(i==j) continue;
if(!games[i][j] && getsToWinTo(i,j))
{
cout<<i<<' '<<j<<endl;
done=true;
break;
}
}
if(done) break;
}
//cin>>a;
return 0;
}
That's the reason of PE, not the ' '.
Can someone post an idea for Problem E ?
Thanx ! :)
hope can do something to you.
i want to know how to do C and E.
Other solution for problem E could be:
* Factorize N (assume that M will be the number of prime factors) -- O(sqrt(N))
* Calculate all the possible arrays b[1..M'] (M' <= M) multiplying i prime factors of N (with i: 0 <= i <= m) -- O(M * 2 ^ M))
* Sort the resulting array b[1..M'] in non-increasing order -- O(M' log M')
* Calculate a number X (X = 2 ^ (b[1] - 1) * 3 ^ (b[2] - 1]) * 5 ^ (b[3] - 1) ...) -- O(M' log N)
* Take the minimum X among all the possible arrays -- O(sqrt(N) + M * 2 ^ M * (M' log M' + M' log N)). This algorithm will run in time.
For example,
N = 16
* b = [2, 2, 2, 2] -> 210
* b = [4, 2, 2] -> 120
* b = [4, 4] -> 216
* b = [8, 2] -> 384
* b = [16] -> 32678
(Some arrays may appear several times)
I wanted to share this information with you, but, IMO DP is a more elegant (and shorter) solution for this problem =).
I`m getting WA :((