Yes!
There's not any restriction on the number of attempts.It doesn't matter whether you were able to clear it last time or not.If you are a student of class 12 or below,you can participate in it.
INOI will be held early this year,maybe in early December.I am not sure yet,but things will be clear soon!
Full Solution:
Now imagine how our shortest path from S to T will look like.Let's denote the component in which S lies by A and the component in which T lies by B.Its not possible to reach T without entering the component B(as T lies in component B and S in component A).Consider the earliest moment when we reach component B from A,let that edge ...
Looking for hints,here we go
IOITC syllabus is almost similar to that of IOI. U can also see the problems at IOITC judge to get some idea.
i would rather suggest you to concentrate on jee,otherwise u will regret ur whole life !
It is a classical problem.Number of swaps needed is nothing but the number of inversions in the array.
I have solved it using BIT,below is my code.
#include <bits/stdc++.h>using namespace std;const int MAX=5e5;long long int N,X,ans,arr[MAX];map<long long int,long long int> mp;int BITS[MAX];void update(int X,int delta){while(X<=N){BITS[X]+=delta;X+=(X&-X);}}int query(int X){int res=0;while(X>0)