#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
long long cnt;
vector<int> mrge(const vector<int>& left, const vector<int>& right)
{
vector<int> result;
unsigned left_it = 0, right_it = 0;
int ll=left.size(), rl=right.size();
while(left_it <ll && right_it < rl)
{
if(left[left_it] < right[right_it])
{
result.push_back(left[left_it]);
left_it++;
}
else
{
result.push_back(right[right_it]);
right_it++;
cnt+=(ll-left_it);
}
}
while(left_it < left.size())
{
result.push_back(left[left_it]);
left_it++;
}
while(right_it < right.size())
{
result.push_back(right[right_it]);
right_it++;
}
return result;
}
vector<int> merge_sort(vector<int>& vec)
{
if(vec.size() == 1) return vec;
vector<int>::iterator middle = vec.begin() + (vec.size() / 2);
vector<int> left(vec.begin(), middle);
vector<int> right(middle, vec.end());
left = merge_sort(left);
right = merge_sort(right);
return mrge(left, right);
}
int main()
{
int n,x;
while(scanf("%d",&n)==1 && n)
{
vector<int>v;
cnt=0;
for(int i=0;i<n;i++)
{
scanf("%d",&x);
v.push_back(x);
}
vector<int> res=merge_sort(v);
printf("%lld\n",cnt);
//if(cnt%2) cout<<"Marcelo"<<endl;
//else cout<<"Carlos"<<endl;
}
return 0;
}
Wednesday, 20 February 2013
UVa 11495 - Bubbles and Buckets Solution
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
long long cnt;
vector<int> mrge(const vector<int>& left, const vector<int>& right)
{
vector<int> result;
unsigned left_it = 0, right_it = 0;
int ll=left.size(), rl=right.size();
while(left_it <ll && right_it < rl)
{
if(left[left_it] < right[right_it])
{
result.push_back(left[left_it]);
left_it++;
}
else
{
result.push_back(right[right_it]);
right_it++;
cnt+=(ll-left_it);
}
}
while(left_it < left.size())
{
result.push_back(left[left_it]);
left_it++;
}
while(right_it < right.size())
{
result.push_back(right[right_it]);
right_it++;
}
return result;
}
vector<int> merge_sort(vector<int>& vec)
{
if(vec.size() == 1) return vec;
vector<int>::iterator middle = vec.begin() + (vec.size() / 2);
vector<int> left(vec.begin(), middle);
vector<int> right(middle, vec.end());
left = merge_sort(left);
right = merge_sort(right);
return mrge(left, right);
}
int main()
{
int n,x;
while(scanf("%d",&n)==1 && n)
{
vector<int>v;
cnt=0;
for(int i=0;i<n;i++)
{
scanf("%d",&x);
v.push_back(x);
}
vector<int> res=merge_sort(v);
//printf("%lld\n",cnt);
if(cnt%2) cout<<"Marcelo"<<endl;
else cout<<"Carlos"<<endl;
}
return 0;
}
Friday, 15 February 2013
how to play incomplete video in IDM
Suppose you start downloading a video using IDM (Internet Download Manager) and due to some reason, it fails when downloading reaches 99%. That feels very bad. But, the bigger reason for disappointment is that it has no resume capability! So, in such conditions, you are left with no other choice other than downloading the file again from the beginning and that’s what IDM advices you too. But do you know that you can even play incomplete downloaded videos in IDM?
things to do:
1. Type %aapdata% in RUN dialog box. press OK
2. idm>>DwnlData>>ReturnZero. here ReturnZero is my user name, your folder name is different
3. now try with a little brain, find the file in the folders, usually is remains in the top folder, you may check file name and file size.
4. after finding the file play it with kmp/vlc. (first open kmp/vlc, then drag the file)
this is all on how to play incomplete downloaded videos in Internet Download Manager
things to do:
1. Type %aapdata% in RUN dialog box. press OK
2. idm>>DwnlData>>ReturnZero. here ReturnZero is my user name, your folder name is different
3. now try with a little brain, find the file in the folders, usually is remains in the top folder, you may check file name and file size.
4. after finding the file play it with kmp/vlc. (first open kmp/vlc, then drag the file)
this is all on how to play incomplete downloaded videos in Internet Download Manager
Format Pendrive using cmd
open cmd
type format h: /fs:fat32
type format h: /fs:fat32
Here 'h' is a drive letter.Press Enter & give name to your Pendrive or USB.
Then after the process is over now your drive is fresh, and ready to be written.
Monday, 11 February 2013
some fun websites
http://www.members.shaw.ca/gf3/circle-the-cat.html
http://www.majman.net/flyswatter/
http://www.simonpanrucker.com/beans.swf
http://fc01.deviantart.net/fs13/f/2007/077/2/e/Animator_vs__Animation_by_alanbecker.swf
http://dontclick.it/
http://www.phong.com/
http://phong.com/beta.php
http://neave.com/bouncy-balls/
http://yugop.com/
http://www.majman.net/flyswatter/
http://www.simonpanrucker.com/beans.swf
http://fc01.deviantart.net/fs13/f/2007/077/2/e/Animator_vs__Animation_by_alanbecker.swf
http://dontclick.it/
http://www.phong.com/
http://phong.com/beta.php
http://neave.com/bouncy-balls/
http://yugop.com/
Sunday, 10 February 2013
Block Ads
wanna get ride of the annoying ads of different websites (facebook, youtube etc)?
install "AdBlock Plus". add-on(mozilla)/extension(chrome).
install "AdBlock Plus". add-on(mozilla)/extension(chrome).
Subscribe to:
Posts (Atom)