From e82df5315bca9913094128bd4a9ab835e0b73bd0 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Sat, 25 Jul 2020 15:17:26 -0500 Subject: [PATCH] Fixed line endings --- .gitignore | 16 ++++----- .vscode/settings.json | 8 ++--- README.md | 6 ++-- gymnastics.cpp | 66 +++++++++++++++++------------------ lineup.cpp | 10 +++--- lineup.java | 4 +-- lineup.txt | 26 +++++++------- photo.py | 72 +++++++++++++++++++------------------- triangles.py | 80 +++++++++++++++++++++---------------------- whereami.cpp | 66 +++++++++++++++++------------------ word.py | 28 +++++++-------- 11 files changed, 191 insertions(+), 191 deletions(-) diff --git a/.gitignore b/.gitignore index 44b57ee..031e212 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ -* -!*/ -!*.* -.vscode -*.in -*.out -*.ans -*.exe +* +!*/ +!*.* +.vscode +*.in +*.out +*.ans +*.exe diff --git a/.vscode/settings.json b/.vscode/settings.json index bab68c5..91e2cef 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ -{ - "files.associations": { - "iosfwd": "cpp" - } +{ + "files.associations": { + "iosfwd": "cpp" + } } \ No newline at end of file diff --git a/README.md b/README.md index a8191b6..79aeec3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# USACO-Demo - -The solutions here are for the USACO 2019 December Contest, Bronze. +# USACO-Demo + +The solutions here are for the USACO 2019 December Contest, Bronze. diff --git a/gymnastics.cpp b/gymnastics.cpp index 7789ded..887ed98 100644 --- a/gymnastics.cpp +++ b/gymnastics.cpp @@ -1,34 +1,34 @@ -#include -using namespace std; - -int main() { - ifstream cin("gymnastics.in"); - ofstream cout("gymnastics.out"); - - int K, N; - cin >> K >> N; - - int rnk[11][22]; - for (int i = 1; i <= K; ++i) { - for (int j = 1; j <= N; ++j) { - int cow; - cin >> cow; - rnk[i][cow] = j; - } - } - - int ans = 0; - for (int a = 1; a <= N; ++a) { - for (int b = 1; b <= N; ++b) { - if (a == b) continue; - - bool better = true; - for (int i = 1; i <= K; ++i) { - if (rnk[i][a] > rnk[i][b]) better = false; - } - - if (better) ++ans; - } - } - cout << ans; +#include +using namespace std; + +int main() { + ifstream cin("gymnastics.in"); + ofstream cout("gymnastics.out"); + + int K, N; + cin >> K >> N; + + int rnk[11][22]; + for (int i = 1; i <= K; ++i) { + for (int j = 1; j <= N; ++j) { + int cow; + cin >> cow; + rnk[i][cow] = j; + } + } + + int ans = 0; + for (int a = 1; a <= N; ++a) { + for (int b = 1; b <= N; ++b) { + if (a == b) continue; + + bool better = true; + for (int i = 1; i <= K; ++i) { + if (rnk[i][a] > rnk[i][b]) better = false; + } + + if (better) ++ans; + } + } + cout << ans; } \ No newline at end of file diff --git a/lineup.cpp b/lineup.cpp index a5dc4a2..7121a4b 100644 --- a/lineup.cpp +++ b/lineup.cpp @@ -1,6 +1,6 @@ -#include -using namespace std; - -int main() { - +#include +using namespace std; + +int main() { + } \ No newline at end of file diff --git a/lineup.java b/lineup.java index bc279d8..a63e60e 100644 --- a/lineup.java +++ b/lineup.java @@ -1,3 +1,3 @@ -public class lineup { - +public class lineup { + } \ No newline at end of file diff --git a/lineup.txt b/lineup.txt index efc74b8..15d7db2 100644 --- a/lineup.txt +++ b/lineup.txt @@ -1,14 +1,14 @@ -read in N - -constraints[N][2] -for i from 1 to N: - read in constraints[i][1] and constraints[i][2] - -for every permutation P of [ Bessie, Buttercup, Belinda, Beatrice, Bella, Blue, Betsy, Sue ]: - for i from 1 to N: - bad = false - if the position of constraints[i][1] is NOT next to position of constraints[i][2] - then set bad to true - - if NOT bad +read in N + +constraints[N][2] +for i from 1 to N: + read in constraints[i][1] and constraints[i][2] + +for every permutation P of [ Bessie, Buttercup, Belinda, Beatrice, Bella, Blue, Betsy, Sue ]: + for i from 1 to N: + bad = false + if the position of constraints[i][1] is NOT next to position of constraints[i][2] + then set bad to true + + if NOT bad then output P \ No newline at end of file diff --git a/photo.py b/photo.py index 5a49bc6..45d4923 100644 --- a/photo.py +++ b/photo.py @@ -1,36 +1,36 @@ -with open("photo.in", "r") as fin: - L = list(fin) - N = int(L[0]) - b = [] - for bi in L[1].split(): - b.append(int(bi)) - - for start in range(1, N + 1): # N - a = [ start ] - for i in range(0, N - 1): # N - a.append(b[i] - a[i]) - - valid = True - appeared = {} - for i in range(0, N): - appeared[a[i]] = False - - for i in range(0, N): - if a[i] < 1: - valid = False - elif a[i] > N: - valid = False - elif appeared[a[i]] == True: - valid = False - appeared[a[i]] = True - - if valid == True: - with open("photo.out", "w") as fout: - firstLine = True - for ai in a: - if firstLine == True: - firstLine = False - else: - fout.write(" ") - fout.write(str(ai)) - exit() +with open("photo.in", "r") as fin: + L = list(fin) + N = int(L[0]) + b = [] + for bi in L[1].split(): + b.append(int(bi)) + + for start in range(1, N + 1): # N + a = [ start ] + for i in range(0, N - 1): # N + a.append(b[i] - a[i]) + + valid = True + appeared = {} + for i in range(0, N): + appeared[a[i]] = False + + for i in range(0, N): + if a[i] < 1: + valid = False + elif a[i] > N: + valid = False + elif appeared[a[i]] == True: + valid = False + appeared[a[i]] = True + + if valid == True: + with open("photo.out", "w") as fout: + firstLine = True + for ai in a: + if firstLine == True: + firstLine = False + else: + fout.write(" ") + fout.write(str(ai)) + exit() diff --git a/triangles.py b/triangles.py index d1c6224..3f293cd 100644 --- a/triangles.py +++ b/triangles.py @@ -1,40 +1,40 @@ -with open("triangles.in", "r") as fin: - L = list(fin) - N = int(L[0]) - - X = [] - Y = [] - for i in range(1, N + 1): - x, y = map(int, L[i].split()) - X.append(x) - Y.append(y) - -ans = 0 -for i in range(0, N): - for j in range(i + 1, N): - for k in range(j + 1, N): - base = 0 - height = 0 - - if X[i] == X[j]: - height = abs(Y[j] - Y[i]) - elif X[j] == X[k]: - height = abs(Y[k] - Y[j]) - elif X[k] == X[i]: - height = abs(Y[i] - Y[k]) - else: - continue - - if Y[i] == Y[j]: - base = abs(X[j] - X[i]) - elif Y[j] == Y[k]: - base = abs(X[k] - X[j]) - elif Y[k] == Y[i]: - base = abs(X[i] - X[k]) - else: - continue - - if base*height > ans: ans = base*height - -with open("triangles.out", "w") as fout: - fout.write(str(ans)) +with open("triangles.in", "r") as fin: + L = list(fin) + N = int(L[0]) + + X = [] + Y = [] + for i in range(1, N + 1): + x, y = map(int, L[i].split()) + X.append(x) + Y.append(y) + +ans = 0 +for i in range(0, N): + for j in range(i + 1, N): + for k in range(j + 1, N): + base = 0 + height = 0 + + if X[i] == X[j]: + height = abs(Y[j] - Y[i]) + elif X[j] == X[k]: + height = abs(Y[k] - Y[j]) + elif X[k] == X[i]: + height = abs(Y[i] - Y[k]) + else: + continue + + if Y[i] == Y[j]: + base = abs(X[j] - X[i]) + elif Y[j] == Y[k]: + base = abs(X[k] - X[j]) + elif Y[k] == Y[i]: + base = abs(X[i] - X[k]) + else: + continue + + if base*height > ans: ans = base*height + +with open("triangles.out", "w") as fout: + fout.write(str(ans)) diff --git a/whereami.cpp b/whereami.cpp index 3237838..7f301e0 100644 --- a/whereami.cpp +++ b/whereami.cpp @@ -1,34 +1,34 @@ -#include -using namespace std; - -int main() { - ifstream cin("whereami.in"); - ofstream cout("whereami.out"); - - int N; - cin >> N; - string S; - cin >> S; - - for (int K = 1; K <= N; ++K) { - bool good = true; - - for (int a = 0; a <= N - K; ++a) { - for (int b = 0; b <= N - K; ++b) { - if (a == b) continue; - - bool string_equal = true; - for (int i = 0; i <= K - 1; ++i) { - if (S[a + i] != S[b + i]) string_equal = false; - } - - if (string_equal) good = false; - } - } - - if (good) { - cout << K; - return 0; - } - } +#include +using namespace std; + +int main() { + ifstream cin("whereami.in"); + ofstream cout("whereami.out"); + + int N; + cin >> N; + string S; + cin >> S; + + for (int K = 1; K <= N; ++K) { + bool good = true; + + for (int a = 0; a <= N - K; ++a) { + for (int b = 0; b <= N - K; ++b) { + if (a == b) continue; + + bool string_equal = true; + for (int i = 0; i <= K - 1; ++i) { + if (S[a + i] != S[b + i]) string_equal = false; + } + + if (string_equal) good = false; + } + } + + if (good) { + cout << K; + return 0; + } + } } \ No newline at end of file diff --git a/word.py b/word.py index 6c407c2..0370994 100644 --- a/word.py +++ b/word.py @@ -1,15 +1,15 @@ -with open("word.in", "r") as fin: - L = list(fin) - N, K = map(int, L[0].split()) # "10" "7" - with open("word.out", "w") as fout: - curLen = 0 # current length of line - for word in L[1].split(): # go through each word - if curLen + len(word) > K: # place on new line - fout.write("\n") - fout.write(word) - curLen = len(word) - else: # place on current line - if curLen > 0: - fout.write(" ") - fout.write(word) +with open("word.in", "r") as fin: + L = list(fin) + N, K = map(int, L[0].split()) # "10" "7" + with open("word.out", "w") as fout: + curLen = 0 # current length of line + for word in L[1].split(): # go through each word + if curLen + len(word) > K: # place on new line + fout.write("\n") + fout.write(word) + curLen = len(word) + else: # place on current line + if curLen > 0: + fout.write(" ") + fout.write(word) curLen += len(word) \ No newline at end of file