Skip to content

Commit 6543f9b

Browse files
Michael  ChenMichael  Chen
Michael Chen
authored and
Michael Chen
committed
New commit
1 parent 6d496c5 commit 6543f9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1448
-3
lines changed

.DS_Store

10 KB
Binary file not shown.

1089G/1089G.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/1089G"
6+
}
7+
]
8+
}

1089G/a.out

15.5 KB
Binary file not shown.

1089G/ans.cpp

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
typedef vector<int> vi;
7+
8+
#define mp make_pair
9+
#define pb push_back
10+
11+
int main() {
12+
#if defined(SUBLIME_RUN) || defined(USE_INPUT_FILE)
13+
freopen("input.txt", "r", stdin);
14+
#endif
15+
ios::sync_with_stdio(0);
16+
int t; cin >> t;
17+
vi days(7);
18+
19+
while (t--) {
20+
// cout << t<< endl;
21+
int ans = INT_MAX;
22+
int k; cin >> k;
23+
int ones = 0;
24+
for (int i=0; i<7; ++i) {
25+
cin >> days[i];
26+
ones += days[i];
27+
}
28+
29+
int goal = k%ones;
30+
// cout << goal << endl;
31+
for (int start=0; start<7; ++start) {
32+
if (!days[start]) continue;
33+
34+
int cur = 1;
35+
int ind = start;
36+
while (cur != goal) {
37+
++ind;
38+
// cout << cur << endl;
39+
ind %= 7;
40+
if (days[ind]) {
41+
++cur;
42+
cur %= ones;
43+
}
44+
}
45+
int end = ind;
46+
// printf("%d %d\n", start, end);
47+
if (end < start) end += 7;
48+
ans = min(ans, 1+7*((k-1)/ones)+end-start);
49+
}
50+
cout << ans << endl;
51+
}
52+
}
53+

1089G/input.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
3
2+
2
3+
0 1 0 0 0 0 0
4+
5
5+
1 0 0 0 1 0 1
6+
1
7+
1 0 0 0 0 0 0

1089G/zzz

15.6 KB
Binary file not shown.

1090M/1090M.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/1090M"
6+
}
7+
]
8+
}

1090M/a.out

15.5 KB
Binary file not shown.

1090M/ans.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
typedef vector<int> vi;
7+
8+
#define mp make_pair
9+
#define pb push_back
10+
11+
int main() {
12+
#if defined(SUBLIME_RUN) || defined(USE_INPUT_FILE)
13+
freopen("input.txt", "r", stdin);
14+
#endif
15+
ios::sync_with_stdio(0);
16+
int n, k;
17+
cin >> n >> k;
18+
vi a(n);
19+
for (int i=0; i<n; ++i) cin >> a[i];
20+
21+
int ans = 1;
22+
int ind = 0;
23+
while (ind < n) {
24+
int start = ind;
25+
while (ind < n && a[ind] != a[ind+1]) {
26+
++ind;
27+
}
28+
// printf("%d %d\n", start, ind);
29+
ind = min(ind, n-1);
30+
ans = max(ans, ind-start+1);
31+
++ind;
32+
33+
}
34+
cout << ans << endl;
35+
}

1090M/input.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
5 2
2+
2 2 2 2 2
3+
4+
8 3
5+
1 2 3 3 2 1 2 2

1090M/zzz

15.6 KB
Binary file not shown.

StringTrie/StringTrie.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/StringTrie"
6+
}
7+
]
8+
}

StringTrie/ans.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
typedef vector<int> vi;
7+
8+
#define mp make_pair
9+
#define pb push_back
10+
// int no
11+
int main() {
12+
#if defined(SUBLIME_RUN) || defined(USE_INPUT_FILE)
13+
freopen("input.txt", "r", stdin);
14+
#endif
15+
ios::sync_with_stdio(0);
16+
17+
}

StringTrie/input.txt

Whitespace-only changes.

USACO/.DS_Store

0 Bytes
Binary file not shown.

USACO/jan 2018/A/ans.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ typedef pair<int, int> pii;
1010
int main() {
1111
#ifdef LOCAL
1212
freopen("a.in", "r", stdin);
13-
#else
14-
freopen("A.in", "r", stdin);
15-
freopen("A.out", "w", stdout);
1613
#endif
1714
ios::sync_with_stdio(0);
1815

16+
1917
}

assign/a.out

68.3 KB
Binary file not shown.

assign/ans.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
typedef vector<int> vi;
7+
8+
#define mp make_pair
9+
#define pb push_back
10+
11+
char c[55];
12+
int cowa[55];
13+
int cowb[55];
14+
int type[55];
15+
int N, K;
16+
int ans = 0;
17+
void rec(int ind) {
18+
if (ind > N) {
19+
for (int i=0; i<K; ++i) {
20+
if ((c[i] == 'S' && type[cowa[i]] != type[cowb[i]]) || (c[i] == 'D' && \
21+
type[cowa[i]] == type[cowb[i]])) {
22+
return;
23+
}
24+
}
25+
ans++;
26+
return;
27+
}
28+
for (int i=1; i<=3; ++i) {
29+
type[ind] = i;
30+
rec(ind+1);
31+
}
32+
}
33+
int main() {
34+
#if defined(SUBLIME_RUN) || defined(USE_INPUT_FILE)
35+
freopen("input.txt", "r", stdin);
36+
#endif
37+
ios::sync_with_stdio(0);
38+
cin >> N >> K;
39+
for (int i=0; i<K; ++i) {
40+
cin >> c[i] >> cowa[i] >> cowb[i];
41+
}
42+
rec(1);
43+
cout << ans << endl;
44+
}

assign/assign.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/assign"
6+
}
7+
]
8+
}

assign/input.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4 2
2+
S 1 2
3+
D 1 3

assign/zzz

11.3 KB
Binary file not shown.

balance/a.out

9.7 KB
Binary file not shown.

balance/ans.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
typedef vector<int> vi;
7+
8+
#define mp make_pair
9+
#define pb push_back
10+
11+
bool visited[10000];
12+
int main() {
13+
#if defined(USE_INPUT_FILE) || defined(SUBLIME_RUN)
14+
freopen("input.txt", "r", stdin);
15+
#endif
16+
ios::sync_with_stdio(0);
17+
int N;
18+
cin >> N;
19+
int ans = 0;
20+
while (!visited[N]) {
21+
++ans;
22+
visited[N] = true;
23+
N = (N/10) % 100;
24+
N*=N;
25+
}
26+
27+
cout << ans << endl;
28+
}

balance/balance.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/balance"
6+
}
7+
]
8+
}

balance/input.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7339

balance/zzz

9.83 KB
Binary file not shown.

checklist/a.out

9.88 KB
Binary file not shown.

checklist/ans.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
typedef vector<int> vi;
7+
8+
#define mp make_pair
9+
#define pb push_back
10+
#define INF 1e9
11+
12+
pii hol[1005], guer[1005];
13+
int dp_h[1005][1005], dp_g[1005][1005];
14+
int sqdist(pii a, pii b) {
15+
return (a.first-b.first)*(a.first-b.first) + (a.second-b.second) * (a.second-b.second);
16+
}
17+
int main() {
18+
freopen("checklist.in", "r", stdin);
19+
freopen("checklist.out", "w", stdout);
20+
#if defined(SUBLIME_RUN) || defined(USE_INPUT_FILE)
21+
freopen("input.txt", "r", stdin);
22+
#endif
23+
ios::sync_with_stdio(0);
24+
int H, G;
25+
cin >> H >> G;
26+
for (int i=1; i<=H; ++i) {
27+
cin >> hol[i].first >> hol[i].second;
28+
}
29+
for (int i=1; i<=G; ++i ){
30+
cin >> guer[i].first >> guer[i].second;
31+
}
32+
for (int i=0; i<H+2; ++i) {
33+
for (int j=0; j<G+2; ++j) {
34+
dp_h[i][j] = INF;
35+
dp_g[i][j] = INF;
36+
}
37+
}
38+
dp_h[1][0] = 0;
39+
for (int i=1; i<=H; ++i) {
40+
for (int j=0; j<=G; ++j) {
41+
if (i == 1 && j == 0)
42+
continue;
43+
if (i > 0) {
44+
dp_h[i][j] = min(dp_h[i-1][j] + sqdist(hol[i-1], hol[i]),\
45+
dp_g[i-1][j] + sqdist(guer[j], hol[i]));
46+
}
47+
48+
if (j>0) {
49+
dp_g[i][j] = min(dp_g[i][j-1] + sqdist(guer[j-1], guer[j]),\
50+
dp_h[i][j-1] + sqdist(hol[i], guer[j]));
51+
}
52+
}
53+
}
54+
cout << dp_h[H][G] << endl;
55+
}

checklist/checklist.out

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
19802

checklist/checklist.sublime-project

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"path": "/Users/chen.young/code/checklist"
6+
}
7+
]
8+
}

checklist/input.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2 2
2+
0 0
3+
0 0
4+
0 1
5+
0 100
6+
7+
3 2
8+
0 0
9+
1 0
10+
2 0
11+
0 3
12+
1 3

checklist/zzz

14.2 KB
Binary file not shown.

cowjog/a.out

34.1 KB
Binary file not shown.

cowjog/zzz

-92 Bytes
Binary file not shown.

cowrun/a.out

9.77 KB
Binary file not shown.

cowrun/ans.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef long long ll;
5+
typedef pair<int, int> pii;
6+
typedef vector<int> vi;
7+
8+
#define mp make_pair
9+
#define pb push_back
10+
11+
int dp[10005][505];
12+
int dist[10005];
13+
int main() {
14+
#if defined(SUBLIME_RUN) || defined(USE_INPUT_FILE)
15+
freopen("input.txt", "r", stdin);
16+
#endif
17+
ios::sync_with_stdio(0);
18+
19+
int N, M;
20+
cin >> N >> M;
21+
for (int i=0; i<N; ++i) {
22+
cin >> dist[i];
23+
}
24+
25+
for (int i=N-1; i>=0; --i) {
26+
for (int j=0; j<=M; ++j) {
27+
if (i+j >= N+1) {
28+
dp[i][j] = INT_MIN;
29+
continue;
30+
}
31+
if (i == N-1) continue;
32+
dp[i][j] = dp[i+j][0];
33+
if (j == 0) dp[i][j] = max(dp[i][j], dp[i+1][j]);
34+
if (j < M)
35+
dp[i][j] = max(dp[i][j], dist[i] + dp[i+1][j+1]);
36+
// printf("%d %d %d\n", i, j, dp[i][j]);
37+
}
38+
}
39+
// cout << dp[7][1] << endl;
40+
cout << dp[0][0] << endl;
41+
42+
}

0 commit comments

Comments
 (0)