Skip to content

Commit

Permalink
dell changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aajjbb committed Jun 13, 2016
1 parent 8f4c6a9 commit f1ce923
Show file tree
Hide file tree
Showing 17 changed files with 250 additions and 11 deletions.
1 change: 0 additions & 1 deletion Codechef/.#ChefLeftAndRight.cpp

This file was deleted.

1 change: 0 additions & 1 deletion Codeforces/.#CountingMixStrings.cpp

This file was deleted.

1 change: 0 additions & 1 deletion Codeforces/.#Xortion.cpp

This file was deleted.

1 change: 0 additions & 1 deletion Csacademy/.#SimilarWords.cpp

This file was deleted.

39 changes: 39 additions & 0 deletions LiveArchive/Box.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 110;

int T;
int N, M;
int P[MAXN][MAXN];

int main() {
cin >> T;

while (T--) {
cin >> N >> M;

for (int i= 0; i < N; i++) {
for (int j = 0; j < M; j++) {
cin >> P[i][j];
}
}

int ans = 0;

for (int i = N - 1; i >= 0; i--) {
for (int j = 0; j < M; j++) {
int k = i;

while (k + 1 < N && P[k][j] == 1 && P[k + 1][j] == 0) {
swap(P[k][j], P[k + 1][j]);
ans += 1;
k++;
}
}
}
cout << ans << "\n";
}
return 0;
}
78 changes: 78 additions & 0 deletions LiveArchive/GolfField.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 30030;

int T, N;
pair<double, double> P[MAXN];

double trap(pair<double, double> a, pair<double, double> b) {
return (0.5*(b.first - a.first)*(b.second + a.second));
}

double area(vector<pair<double, double> > vin) {
int n = vin.size();

sort(vin.begin(), vin.end());
double ans = 0;

do {
double ret = 0.0;
for(int i = 0; i < n; i++) {
ret += trap(vin[i], vin[(i+1)%n]);
}
ans = max(ans, fabs(ret));
} while (next_permutation(vin.begin(), vin.end()));

return fabs(ans);
}

double tryA(int base) {
vector<pair<double, double> > vs;

for (int i = 0; i < base; i++) {
vs.push_back(P[i]);
}

for (int i = base; i < N; i++) {
vector<pair<double, double> > buff = vs;
double curr_area = area(buff);
double best = 0;
int id = -1;

for (int j = 0; j < base; j++) {
swap(buff[j], P[i]);
if (area(buff) >= curr_area) {
curr_area = area(buff);
id = j;
}
swap(buff[j], P[i]);
}
if (id != -1) {
vs = buff;
buff[id] = P[i];
}
vs = buff;
}
return area(vs);
}

int main() {
cin >> T;

while (T--) {
cin >> N;

for (int i = 0; i < N; i++) {
cin >> P[i].first >> P[i].second;
}

sort(P, P + N);

double ans = tryA(3);

cout << fixed << setprecision(1) << ans << "\n";
}
return 0;
}
79 changes: 79 additions & 0 deletions LiveArchive/Metal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 10005;

const double EPS = 1e-9;

int T, N, K;
pair<double, double> P[MAXN];

int check(double rc) {
int ans = 1, used = 0;
double sum = 0.0;
double s = INT_MAX;
double l = INT_MIN;

for (int i = 0; i < N; i++) {
sum += P[i].second;
used += 1;

s = min(s, P[i].second);
l = max(l, P[i].second);

double pos_y = 0;

pos_y = s + (l - s) / 2.0;

//cout << fixed << setprecision(10) << i << " " << rc << " " << ans << " " << pos_y << " " << max(fabs(s - pos_y), fabs(l - pos_y)) << "\n";


if (max(fabs(s - pos_y), fabs(l - pos_y)) - EPS > rc) {

ans += 1;

s = P[i].second;
l = P[i].second;
used = 1;
sum = P[i].second;
}
}

return ans;
}

int main() {
cin >> T;

while (T--) {
cin >> N >> K;

for (int i = 0; i < N; i++) {
cin >> P[i].first;
cin >> P[i].second;
}

sort(P, P + N);

double l = 0.0, h = 20000000000.0, m;
double best = 0;

for (int cnt = 0; cnt < 100; cnt++) {
m = (l + h) / 2.0;

int used = check(m);
//cout << used << " " << m << "\n";

if (used <= K) {
best = m;
h = m;
} else {
l = m;
}
}

cout << fixed << setprecision(1) << best << "\n";
}
return 0;
}
54 changes: 54 additions & 0 deletions LiveArchive/PermutationGraphs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <bits/stdc++.h>

using namespace std;

typedef long long Int;

const int MAXN = 100005;

int T, N;
int A[MAXN];
int B[MAXN];
int P[MAXN];
Int bit[MAXN];

Int query(int pos) {
Int ans = 0;

for (int i = pos; i > 0; i -= (i & -i)) {
ans += bit[i];
}

return ans;
}

void update(int pos) {
for (int i = pos; i <= N; i += (i & -i)) {
bit[i] += 1;
}
}
int main() {
cin >> T;

while (T--) {
cin >> N;

memset(bit, 0, sizeof(bit));

for (int i = 1; i <= N; i++) {
cin >> A[i];
P[A[i]] = i;
}

Int ans = 0;

for (int i = 1; i <= N; i++) {
cin >> B[i];
B[i] = P[B[i]];
ans += (query(N) - query(B[i]));
update(B[i]);
}
cout << ans << "\n";
}
return 0;
}
1 change: 0 additions & 1 deletion MainPL/.#MarketPlace.cpp

This file was deleted.

1 change: 0 additions & 1 deletion MainPL/.#TheHero.cpp

This file was deleted.

1 change: 0 additions & 1 deletion TC/.#308-DIV2-450.java

This file was deleted.

1 change: 0 additions & 1 deletion TC/.#671-DIV2-1000.cpp

This file was deleted.

1 change: 0 additions & 1 deletion URI/.#Melborpa.cpp

This file was deleted.

1 change: 0 additions & 1 deletion URI/.#Rabiola.cpp

This file was deleted.

1 change: 0 additions & 1 deletion URI/.#Shuffling.cpp

This file was deleted.

Binary file removed URI/.Emoticons.cpp.swo
Binary file not shown.
Binary file removed URI/.Emoticons.cpp.swp
Binary file not shown.

0 comments on commit f1ce923

Please sign in to comment.