Skip to content

Commit 9cf9f77

Browse files
committed
backup some contests and reorginize folders
1 parent e46d212 commit 9cf9f77

Some content is hidden

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

91 files changed

+2564
-332284
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
*.in
77
*.out
88
/topcoder/*.txt
9+
/12unning

a2oj/acpc2016/a.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int t;
7+
scanf("%d", &t);
8+
while (t--) {
9+
int n, q;
10+
scanf("%d %d", &n, &q);
11+
int l, r;
12+
scanf("%d %d", &r, &l);
13+
if (l < r)
14+
swap(l, r);
15+
for (int i= 1; i < n; i++) {
16+
int a, b;
17+
scanf("%d %d", &a, &b);
18+
if (a > b)
19+
swap(a, b);
20+
l = min(b, l);
21+
r = max(a, r);
22+
}
23+
while (q--) {
24+
int a;
25+
scanf("%d", &a);
26+
puts((a <= r && a >= l) ? "YES" : "NOT SURE");
27+
}
28+
}
29+
return 0;
30+
}

a2oj/acpc2016/c.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int t;
7+
scanf("%d", &t);
8+
while (t--) {
9+
int g, c, e;
10+
scanf("%d %d %d", &g, &c, &e);
11+
int need = max(e-c, 0);
12+
printf("%d\n", need * (2 * g - 1));
13+
}
14+
return 0;
15+
}

a2oj/acpc2016/e.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int x[3], mx[3], ax[3];
6+
7+
int main() {
8+
int t;
9+
scanf("%d", &t);
10+
while (t--) {
11+
for (int i = 0; i < 3; i++)
12+
scanf("%d", x+i);
13+
int n;
14+
scanf("%d", &n);
15+
if (n == 0) {
16+
int ans = 0;
17+
for (int i = 0; i < 3; i++)
18+
ans ^= (x[i]-1);
19+
puts(ans ? "Alice" : "Bob");
20+
continue;
21+
}
22+
for (int i= 0; i < 3; i++) {
23+
scanf("%d", mx+i);
24+
ax[i] = mx[i];
25+
}
26+
for (int i = 1; i < n; i++) {
27+
int v[3];
28+
for (int j = 0; j < 3; j++) {
29+
scanf("%d", v+j);
30+
mx[j] = min(mx[j], v[j]);
31+
ax[j] = max(ax[j], v[j]);
32+
}
33+
}
34+
int ans = 0;
35+
for (int i = 0; i < 3; i++)
36+
ans ^= (mx[i]-1) ^ (x[i] - ax[i]);
37+
puts(ans ? "Alice" : "Bob");
38+
}
39+
40+
return 0;
41+
}

a2oj/acpc2016/g.cpp

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
const int inf = 1e7;
6+
int dp[2][4];
7+
8+
int main() {
9+
int t;
10+
scanf("%d", &t);
11+
while (t--) {
12+
int n;
13+
scanf("%d", &n);
14+
memset(dp, 0, sizeof dp);
15+
int last = 0;
16+
char s[2][10];
17+
scanf("%s", s[0]);
18+
for (int i = 0; i < 4; i++)
19+
dp[0][i] = inf;
20+
dp[0][0] = 0;
21+
for (int i = 1; i < n; i++) {
22+
int c = i & 1, b = !c;
23+
scanf("%s", s[c]);
24+
for (int j = 0; j < 4; j++) {
25+
dp[c][j] = inf;
26+
for (int k = 0; k < 4; k++) {
27+
if (j == 3 && s[c][0] == s[b][0] && s[c][1] == s[b][1]) {
28+
dp[c][j] = min(dp[c][j], dp[b][k]);
29+
}
30+
if (j == 2 && s[c][0] == s[b][0]) {
31+
if ((k & 1) == 1)
32+
dp[c][j] = min(dp[c][j], dp[b][k]);
33+
else
34+
dp[c][j] = min(dp[c][j], dp[b][k]+1);
35+
}
36+
if (j == 1 && s[c][1] == s[b][1]) {
37+
if ((k & 2)== 2)
38+
dp[c][j] = min(dp[c][j], dp[b][k]);
39+
else
40+
dp[c][j] = min(dp[c][j], dp[b][k]+1);
41+
}
42+
if (j == 0 && k == 0 && s[b][0] == s[b][1])
43+
dp[c][j] = min(dp[c][j], dp[b][k]);
44+
if (j == 0) {
45+
dp[c][j] = min(dp[c][j], dp[b][k] + 2 - __builtin_popcount(k));
46+
}
47+
}
48+
// cerr << dp[c][j] << " " ;
49+
}
50+
// cerr << i << endl;
51+
}
52+
int ans = inf, c = !(n & 1);
53+
for (int i = 0; i < 4; i++) {
54+
int tmp = dp[c][i] + 2 - __builtin_popcount(i);
55+
if (i == 0 && s[c][0] == s[c][1])
56+
tmp -= 2;
57+
ans = min(ans, tmp);
58+
}
59+
printf("%d\n", ans);
60+
}
61+
return 0;
62+
}

a2oj/acpc2016/i.cpp

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
const int N = 1024;
6+
7+
pair< pair< int, int>, int > p[N];
8+
int vy[N], m, k;
9+
int cnt[N][105], dif[N], mid;
10+
11+
bool add(int y, int z) {
12+
for (int i = 0; i < m; i++) if (vy[i] <= y && y <= vy[i]+mid) {
13+
cnt[i][z]++;
14+
if (cnt[i][z] == 1) {
15+
dif[i]++;
16+
if (dif[i] == k)
17+
return true;
18+
}
19+
}
20+
return false;
21+
}
22+
void del(int y, int z) {
23+
for (int i = 0; i < m; i++) if (vy[i] <= y && y <= vy[i]+mid) {
24+
cnt[i][z]--;
25+
if (cnt[i][z] == 0)
26+
dif[i]--;
27+
}
28+
}
29+
30+
int main() {
31+
int t;
32+
scanf("%d", &t);
33+
while (t--) {
34+
int n;
35+
scanf("%d %d", &n, &k);
36+
for (int i = 0; i < n; i++) {
37+
int x, y, z;
38+
scanf("%d %d %d", &x, &y, &z);
39+
p[i] = make_pair(make_pair(x, y), z);
40+
vy[i] = y;
41+
}
42+
sort(vy, vy+n);
43+
m = unique(vy, vy+n) - vy;
44+
sort(p, p+n);
45+
46+
int l = 1, r = 2e8 + 5;
47+
while (l < r) {
48+
memset(cnt, 0, sizeof cnt);
49+
memset(dif, 0, sizeof dif);
50+
int id = 0;
51+
mid = (l + r) >> 1;
52+
bool ok = false;
53+
for (int i = 0; i < n; i++) {
54+
int x = p[i].first.first, y = p[i].first.second, z = p[i].second;
55+
while (id < i && x - p[id].first.first > mid) {
56+
del(p[id].first.second, p[id].second);
57+
id++;
58+
}
59+
if (add(y, z)) {
60+
ok = true;
61+
break;
62+
}
63+
}
64+
if (ok)
65+
r = mid;
66+
else
67+
l = mid+1;
68+
}
69+
printf("%d\n", l);
70+
}
71+
return 0;
72+
}

a2oj/acpc2016/k.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int t;
7+
cin >> t;
8+
while (t--) {
9+
long long n, k;
10+
cin >> n >> k;
11+
cout << n - (n+k)/(k+1) << endl;
12+
}
13+
return 0;
14+
}

a2oj/acpc2016/l.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
const double pi = acos(-1);
6+
7+
int main() {
8+
int t;
9+
cin >> t;
10+
cout << fixed << setprecision(4);
11+
while (t--) {
12+
double n, s, r;
13+
cin >> n >> s >> r;
14+
double ans = (double)1 - (double)2.0 * r * tan(pi/n) / s;
15+
if (ans < 0)
16+
ans = 0;
17+
ans = (double)1 - ans * ans;
18+
cout << ans << endl;
19+
}
20+
return 0;
21+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

codeforces/SPPC16/a.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
pair< long long, long long> get(long long n) {
6+
if (n == 1)
7+
return make_pair(0, 0);
8+
long long l = 0, r = 31000;
9+
while (l < r) {
10+
long long mid = (l + r + 1) >> 1;
11+
long long k = mid * 2 + 1;
12+
if (k * k < n)
13+
l = mid;
14+
else
15+
r = mid - 1;
16+
}
17+
long long k = l + l + 1;
18+
n -= k * k;
19+
if (n <= k+1)
20+
return make_pair(-(k+1)/2 + n, (k+1)/2);
21+
n -= k+1;
22+
if (n <= k+1)
23+
return make_pair((k+1)/2, (k+1)/2-n);
24+
n -= k+1;
25+
if (n <= k+1)
26+
return make_pair((k+1)/2-n, -(k+1)/2);
27+
n -= k+1;
28+
assert(n <= k+1);
29+
return make_pair(-(k+1)/2, -(k+1)/2+n);
30+
}
31+
32+
int main() {
33+
long long a, b;
34+
cin >> a >> b;
35+
pair< long long, long long> aa = get(a), bb = get(b);
36+
cout << abs(aa.first - bb.first) + abs(aa.second - bb.second) << endl;
37+
38+
return 0;
39+
}

codeforces/SPPC16/b.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
const int N = 1e6 + 5;
6+
7+
vector<pair<int, int>> edge[N]; // ke, id
8+
vector<int> ans;
9+
10+
void dfs(int now, int st) {
11+
for (auto it : edge[now]) {
12+
if (it.second <= st) break;
13+
ans.push_back(it.first);
14+
if (ans.size() > N) break;
15+
dfs(it.first, it.second);
16+
}
17+
}
18+
19+
int main() {
20+
int n, l, r;
21+
scanf("%d %d %d", &n, &l, &r);
22+
for (int i = 0; i < n; i++) {
23+
int u, v;
24+
scanf("%d %d", &u, &v);
25+
edge[u].emplace_back(v, i);
26+
}
27+
for (int i = 0; i < N; i++) reverse(edge[i].begin(), edge[i].end());
28+
ans.push_back(0);
29+
dfs(0, -1);
30+
for (int i = l; i < r; i++) printf("%d ", ans[i % ans.size()]);
31+
return 0;
32+
}

0 commit comments

Comments
 (0)