Browse Source

Add some new stuff

master
Abheek Dhawan 3 years ago
parent
commit
e0955c344b
  1. BIN
      usaco/Breed Counting/a.out
  2. 34
      usaco/Breed Counting/index.cpp
  3. BIN
      usaco/Mixing Milk/a.out
  4. 69
      usaco/Mixing Milk/index.cpp
  5. 3
      usaco/Mixing Milk/mixmilk.in
  6. 3
      usaco/Mixing Milk/mixmilk.out
  7. BIN
      usaco/Shell Game/a.out
  8. 41
      usaco/Shell Game/index.cpp
  9. 0
      usaco/Shell Game/shell.out

BIN
usaco/Breed Counting/a.out

Binary file not shown.

34
usaco/Breed Counting/index.cpp

@ -0,0 +1,34 @@
using namespace std;
#include <cstdio>
#include <iostream>
int main() {
freopen("bcount.in", "r", stdin);
freopen("bcount.out", "w", stdout);
int n, q;
cin >> n >> q;
int cow_array[n];
for (int i = 0; i < n; i++) {
int j;
cin >> j;
cow_array[i] = j;
}
for (int i = 0; i < q; i++) {
int j, k;
cin >> j >> k;
int a = 0;
int b = 0;
int c = 0;
for (int i = 0; i < abs(j - k) + 1; i++) {
if (cow_array[i + j - 1] == 1) {
a++;
} else if (cow_array[i + j - 1] == 2) {
b++;
} else if (cow_array[i + j - 1] == 3) {
c++;
}
}
cout << a << " " << b << " " << c << endl;
}
}

BIN
usaco/Mixing Milk/a.out

Binary file not shown.

69
usaco/Mixing Milk/index.cpp

@ -0,0 +1,69 @@
using namespace std;
#include <iostream>
int main() {
freopen("mixmilk.in", "r", stdin);
freopen("mixmilk.out", "w", stdout);
int a_cap, a_val;
cin >> a_cap >> a_val;
int b_cap, b_val;
cin >> b_cap >> b_val;
int c_cap, c_val;
cin >> c_cap >> c_val;
for (int i = 0; i < 33; i++) {
int a_diff, b_diff, c_diff;
a_diff = abs(a_cap - a_val);
b_diff = abs(b_cap - b_val);
c_diff = abs(c_cap - c_val);
if (b_diff >= a_val) {
b_val += a_val;
a_val = 0;
} else {
b_val = b_cap;
a_val -= b_diff;
}
a_diff = abs(a_cap - a_val);
b_diff = abs(b_cap - b_val);
c_diff = abs(c_cap - c_val);
if (c_diff >= b_val) {
c_val += b_val;
b_val = 0;
} else {
c_val = c_cap;
b_val -= c_diff;
}
a_diff = abs(a_cap - a_val);
b_diff = abs(b_cap - b_val);
c_diff = abs(c_cap - c_val);
if (a_diff >= c_val) {
a_val += c_val;
c_val = 0;
} else {
a_val = a_cap;
c_val -= a_diff;
}
a_diff = abs(a_cap - a_val);
b_diff = abs(b_cap - b_val);
c_diff = abs(c_cap - c_val);
}
int a_diff, b_diff, c_diff;
a_diff = abs(a_cap - a_val);
b_diff = abs(b_cap - b_val);
c_diff = abs(c_cap - c_val);
if (b_diff >= a_val) {
b_val += a_val;
a_val = 0;
} else {
b_val = b_cap;
a_val -= b_diff;
}
cout << a_val << endl << b_val << endl << c_val << endl;
}

3
usaco/Mixing Milk/mixmilk.in

@ -0,0 +1,3 @@
10 3
11 4
12 5

3
usaco/Mixing Milk/mixmilk.out

@ -0,0 +1,3 @@
0
10
2

BIN
usaco/Shell Game/a.out

Binary file not shown.

41
usaco/Shell Game/index.cpp

@ -0,0 +1,41 @@
using namespace std;
#include <cstdio>
#include <iostream>
int main() {
freopen("shell.in", "r", stdin);
freopen("shell.out", "w", stdout);
int n;
cin >> n;
int score = 0;
int a_values[n];
int b_values[n];
int g_values[n];
for (int i = 0; i < n; i++) {
cin >> a_values[i] >> b_values[i] >> g_values[i];
}
int shell_num;
shell_num = 0;
for (int i = 0; i < 3; i++) {
shell_num = i + 1;
for (int j = 0; j < n; j++) {
int a, b, g;
a = a_values[i];
b = b_values[i];
g = g_values[i];
if (a == shell_num) {
shell_num = b;
} else if (b == shell_num) {
shell_num = a;
}
if (g == shell_num) {
score++;
}
}
}
cout << score << endl;
}

0
usaco/Shell Game/shell.out

Loading…
Cancel
Save