Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 9140c4b

Browse files
author
ZhangZisu
committed
2019-02-13 Update
1 parent add0035 commit 9140c4b

File tree

20 files changed

+813
-1
lines changed

20 files changed

+813
-1
lines changed

.vscode/settings.json

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
11
{
22
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 8, ColumnLimit: 0, UseTab: Always}",
3-
"C_Cpp.intelliSenseEngineFallback": "Enabled"
3+
"C_Cpp.intelliSenseEngineFallback": "Enabled",
4+
"files.associations": {
5+
"cstdlib": "cpp",
6+
"cstdio": "cpp",
7+
"array": "cpp",
8+
"*.tcc": "cpp",
9+
"cctype": "cpp",
10+
"clocale": "cpp",
11+
"cmath": "cpp",
12+
"complex": "cpp",
13+
"cstdint": "cpp",
14+
"cstring": "cpp",
15+
"ctime": "cpp",
16+
"cwchar": "cpp",
17+
"cwctype": "cpp",
18+
"deque": "cpp",
19+
"unordered_map": "cpp",
20+
"vector": "cpp",
21+
"exception": "cpp",
22+
"fstream": "cpp",
23+
"initializer_list": "cpp",
24+
"iosfwd": "cpp",
25+
"iostream": "cpp",
26+
"istream": "cpp",
27+
"limits": "cpp",
28+
"new": "cpp",
29+
"optional": "cpp",
30+
"ostream": "cpp",
31+
"sstream": "cpp",
32+
"stdexcept": "cpp",
33+
"streambuf": "cpp",
34+
"string_view": "cpp",
35+
"system_error": "cpp",
36+
"type_traits": "cpp",
37+
"tuple": "cpp",
38+
"typeinfo": "cpp",
39+
"utility": "cpp"
40+
}
441
}

_collection/AtCoder/yahoo_procon2019_qual_e.cpp

Whitespace-only changes.

_collection/BZOJ/2951.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <algorithm>
2+
#include <cstdio>
3+
#include <cstdlib>
4+
#include <cstring>
5+
#define MAXN 20000
6+
#define MAXV 100000
7+
#define OFFSET 50000
8+
struct point_t {
9+
int x, y;
10+
inline int friend operator<(point_t a, point_t b) {
11+
return a.x < b.x;
12+
}
13+
} p[MAXN];
14+
int n, h, w, ans = 0, max[MAXV << 2], tag[MAXV << 2];
15+
inline void pushDown(int n) {
16+
if (tag[n]) {
17+
max[n << 1] += tag[n], max[n << 1 | 1] += tag[n];
18+
tag[n << 1] += tag[n], tag[n << 1 | 1] += tag[n];
19+
tag[n] = 0;
20+
}
21+
}
22+
void add(int n, int l, int r, int L, int R, int v) {
23+
if (l == L && r == R) return max[n] += v, tag[n] += v, void();
24+
int mid = (l + r) >> 1;
25+
pushDown(n);
26+
if (R <= mid)
27+
add(n << 1, l, mid, L, R, v);
28+
else if (L > mid)
29+
add(n << 1 | 1, mid + 1, r, L, R, v);
30+
else
31+
add(n << 1, l, mid, L, mid, v), add(n << 1 | 1, mid + 1, r, mid + 1, R, v);
32+
max[n] = std::max(max[n << 1], max[n << 1 | 1]);
33+
}
34+
int main() {
35+
scanf("%d%d%d", &w, &h, &n);
36+
for (int i = 1; i <= n; i++) scanf("%d%d", &p[i].x, &p[i].y);
37+
std::sort(p + 1, p + n + 1);
38+
for (int i = 1, j = 1; i <= n; i++) {
39+
for (; j <= n && p[j].x <= p[i].x + w; j++) {
40+
add(1, 1, MAXV, p[j].y - h + OFFSET, p[j].y + OFFSET, 1);
41+
}
42+
ans = std::max(ans, max[1]);
43+
add(1, 1, MAXV, p[i].y - h + OFFSET, p[i].y + OFFSET, -1);
44+
}
45+
printf("%d\n", ans);
46+
return 0;
47+
}

_gym/100965/A.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <algorithm>
2+
#include <cstdio>
3+
#include <cstdlib>
4+
#include <cstring>
5+
#define MAXN 1000010
6+
int n;
7+
double h, a[MAXN];
8+
int main() {
9+
// freopen("alpinism.in", "r", stdin);
10+
// freopen("alpinism.out", "w", stdout);
11+
scanf("%lf%d", &h, &n);
12+
double ans = 1e100;
13+
for (int i = 1; i <= n; i++) {
14+
scanf("%lf", a + i);
15+
double rest = h - a[i];
16+
double tmp = .5 * a[i];
17+
if (tmp <= rest) {
18+
ans = std::min(ans, tmp + rest);
19+
} else {
20+
ans = std::min(ans, a[i]);
21+
}
22+
}
23+
printf("%f\n", ans);
24+
return 0;
25+
}

_gym/100965/D.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <cstdio>
2+
const int W = 1000, H = 1000;
3+
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
4+
bool vis[W][H];
5+
int main() {
6+
for (int i = 0; i < W; i++) {
7+
for (int j = 0; j < H; j++) {
8+
vis[i][j] = gcd(i, j) != 1;
9+
}
10+
}
11+
// for (int i = 0; i < W; i++) {
12+
// for (int j = 0; j < H; j++) {
13+
// if(vis[i][j]&&vis[i+1][j]&&vis[i][j+1]&&vis[i][j])
14+
// }
15+
// }
16+
}

_gym/100965/H.cpp

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
2+
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,abm,mmx,tune=native")
3+
#include <algorithm>
4+
#include <cmath>
5+
#include <cstdio>
6+
#include <cstdlib>
7+
#include <cstring>
8+
#define MAXN 500010
9+
using lnt = long long;
10+
const lnt MOD = 75161927681LL;
11+
const lnt G = 3;
12+
inline lnt mul(lnt x, lnt y) { return (x * y - (lnt)((long double)x / MOD * y) * MOD + MOD) % MOD; }
13+
inline void trim(lnt &x) { x -= MOD, x += (x >> 63) & MOD; }
14+
inline lnt fuck(lnt x, lnt y) {
15+
lnt z = 1;
16+
for (; y; y >>= 1) {
17+
if (y & 1) z = mul(z, x);
18+
x = mul(x, x);
19+
}
20+
return z;
21+
}
22+
lnt wns[20][MAXN], invs[20];
23+
int revs[20][MAXN];
24+
inline void pre() {
25+
for (int n = 1, kk = 0; n < MAXN; n <<= 1, kk++) {
26+
lnt wn = fuck(G, (MOD - 1) / n);
27+
wns[kk][0] = 1;
28+
for (int i = 1; i < (n >> 1); i++) wns[kk][i] = mul(wns[kk][i - 1], wn);
29+
invs[kk] = fuck(n, MOD - 2);
30+
for (int i = 1, j = 0; i < n - 1; i++) {
31+
for (int t = n; ~j & t; j ^= t) t >>= 1;
32+
revs[kk][i] = j;
33+
}
34+
}
35+
}
36+
inline void NTT(int *rev, lnt *a, int n) {
37+
for (int i = 1; i < n - 1; i++) {
38+
if (i < rev[i]) std::swap(a[i], a[rev[i]]);
39+
}
40+
for (int k = 1, kk = 1; k < n; k <<= 1, kk++) {
41+
int t = k << 1;
42+
for (int i = 0; i < n; i += t) {
43+
for (int j = 0; j < k; j++) {
44+
lnt x = a[i + j], y = mul(wns[kk][j], a[i + j + k]);
45+
trim(a[i + j] = x + y);
46+
trim(a[i + j + k] = x - y + MOD);
47+
}
48+
}
49+
}
50+
}
51+
int m, cnt = 0;
52+
lnt f[MAXN], g[MAXN], h[MAXN];
53+
inline std::pair<int, int> solve(int l, int r) {
54+
if (l == r) {
55+
f[cnt++] = (m - l) % m;
56+
f[cnt++] = 1;
57+
return {cnt - 2, 2};
58+
}
59+
int mid = (l + r) >> 1;
60+
auto L = solve(l, mid), R = solve(mid + 1, r);
61+
int n = 1, nn = 0, len = L.second + R.second - 1;
62+
while (n < len) n <<= 1, nn++;
63+
memcpy(g, f + L.first, sizeof(lnt) * L.second);
64+
memset(g + L.second, 0, sizeof(lnt) * (n - L.second));
65+
memcpy(h, f + R.first, sizeof(lnt) * R.second);
66+
memset(h + R.second, 0, sizeof(lnt) * (n - R.second));
67+
NTT(revs[nn], g, n), NTT(revs[nn], h, n);
68+
for (int i = 0; i < n; i++) g[i] = mul(g[i], h[i]);
69+
NTT(revs[nn], g, n);
70+
std::reverse(g + 1, g + n);
71+
lnt inv = invs[nn];
72+
for (int i = 0; i < n; i++) g[i] = mul(g[i], inv) % m;
73+
std::memcpy(f + L.first, g, sizeof(lnt) * len);
74+
return {L.first, len};
75+
}
76+
int main() {
77+
freopen("polynomial.in", "r", stdin);
78+
freopen("polynomial.out", "w", stdout);
79+
pre();
80+
scanf("%d", &m);
81+
auto ans = solve(0, m - 1);
82+
printf("%d\n", ans.second - 1);
83+
for (int i = ans.first + ans.second - 1; i >= ans.first; i--) printf("%lld ", f[i]);
84+
return 0;
85+
}

_gym/100965/K.cpp

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#include <algorithm>
2+
#include <iostream>
3+
#include <map>
4+
#include <set>
5+
#include <string>
6+
#include <vector>
7+
int n, m;
8+
inline bool isVowel(char c) { return c == 'a' || c == 'o' || c == 'y' || c == 'i' || c == 'e'; }
9+
inline bool isConsonant(char c) { return !isVowel(c); }
10+
inline bool isMark(char c) { return c == '.' || c == '!' || c == '?'; }
11+
const std::vector<std::string> se_prefix = {"s", "hs", "hc", "x", "o"};
12+
std::map<std::string, int> nouns, auxiliaries;
13+
std::set<std::string> verbs;
14+
std::vector<std::string> tokens;
15+
inline bool startsWith(const std::string &s, const std::string &p) { return s.compare(0, p.size(), p) == 0; }
16+
std::string goPlural(std::string noun) {
17+
for (const auto &prefix : se_prefix) {
18+
if (startsWith(noun, prefix)) {
19+
return "se" + noun;
20+
}
21+
}
22+
if (startsWith(noun, "f")) return "sev" + noun.substr(1);
23+
if (startsWith(noun, "ef")) return "sev" + noun.substr(2);
24+
if ((int)noun.length() >= 2 && noun[0] == 'y' && isConsonant(noun[1])) return "sei" + noun.substr(1);
25+
return "s" + noun;
26+
}
27+
std::vector<std::string> split(const std::string &str) {
28+
std::vector<std::string> ret;
29+
bool dirty = true;
30+
for (int i = 0; i < (int)str.length(); i++) {
31+
if (isMark(str[i])) {
32+
ret.push_back(std::string() + str[i]);
33+
dirty = true;
34+
} else {
35+
if (dirty) {
36+
dirty = false;
37+
ret.push_back(std::string() + str[i]);
38+
} else {
39+
ret.back().push_back(str[i]);
40+
}
41+
}
42+
}
43+
return ret;
44+
}
45+
int main() {
46+
nouns["i"] |= 1 << 0;
47+
nouns["eh"] |= 1 << 0;
48+
nouns["ehs"] |= 1 << 0;
49+
nouns["ti"] |= 1 << 0;
50+
nouns["uoy"] |= 1 << 1;
51+
nouns["yeht"] |= 1 << 1;
52+
nouns["ew"] |= 1 << 1;
53+
54+
auxiliaries["ma"] |= 1 << 0;
55+
auxiliaries["si"] |= 1 << 0;
56+
auxiliaries["saw"] |= 1 << 0;
57+
auxiliaries["lliw"] |= 1 << 0;
58+
auxiliaries["llahs"] |= 1 << 0;
59+
60+
auxiliaries["era"] |= 1 << 1;
61+
auxiliaries["erew"] |= 1 << 1;
62+
auxiliaries["lliw"] |= 1 << 1;
63+
64+
// freopen("language.in", "r", stdin);
65+
// freopen("language.out", "w", stdout);
66+
std::ios::sync_with_stdio(0);
67+
std::cin >> n >> m;
68+
std::string token;
69+
for (int i = 1; i <= n; i++) {
70+
std::cin >> token;
71+
nouns[token] |= 1 << 0;
72+
nouns[goPlural(token)] |= 1 << 1;
73+
}
74+
for (int i = 1; i <= m; i++) {
75+
std::cin >> token;
76+
verbs.insert(token);
77+
}
78+
while (std::cin >> token) {
79+
const auto splitted = split(token);
80+
for (const auto &token : splitted) {
81+
if (isMark(token.back())) {
82+
// if ((int)token.length() > 1) {
83+
// tokens.push_back(token.substr(0, token.length() - 1));
84+
// }
85+
if (tokens.size() >= 3U && tokens.size() <= 4U) {
86+
if (token.back() == '?') std::swap(tokens[0], tokens[1]);
87+
if (nouns.count(tokens[0]) && auxiliaries.count(tokens[1])) {
88+
if (nouns[tokens[0]] & auxiliaries[tokens[1]]) {
89+
if (tokens.size() == 3U) {
90+
puts(verbs.count(tokens[2]) ? "Yes" : "No");
91+
} else {
92+
puts(tokens[2] == "oy" && verbs.count(tokens[3]) ? "Yes" : "No");
93+
}
94+
} else {
95+
puts("No");
96+
}
97+
} else {
98+
puts("No");
99+
}
100+
} else {
101+
puts("No");
102+
}
103+
tokens.clear();
104+
} else {
105+
tokens.push_back(token);
106+
}
107+
}
108+
}
109+
}

_gym/100965/chk.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <cassert>
2+
#include <cstdio>
3+
int n, m, a[1000];
4+
inline int fuck(int x, int y) {
5+
int z = 1;
6+
for (; y; y >>= 1) {
7+
if (y & 1) z = 1LL * z * x % m;
8+
x = 1LL * x * x % m;
9+
}
10+
return z;
11+
}
12+
int main() {
13+
scanf("%d%d", &m, &n);
14+
for (int i = n; i >= 0; i--) scanf("%d", &a[i]);
15+
for (int d = 0; d < m; d++) {
16+
int tmp = 0;
17+
for (int i = 0, x = 1; i <= n; i++, x = 1LL * x * d % m) {
18+
tmp = (tmp + 1LL * x * a[i] % m) % m;
19+
}
20+
assert(tmp == 0);
21+
}
22+
return 0;
23+
}

_gym/102055/A.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <algorithm>
2+
#include <cstdio>
3+
#include <cstdlib>
4+
#include <cstring>
5+
#define MAXN 100010
6+
int t, n, m;
7+
std::pair<int, int> a[MAXN];
8+
int main() {
9+
scanf("%d", &t);
10+
for (int T = 1; T <= t; T++) {
11+
scanf("%d%d", &n, &m);
12+
for (int i = 1; i <= n; i++) scanf("%d", &a[i].first);
13+
for (int i = 1; i <= n; i++) scanf("%d", &a[i].second);
14+
std::sort(a + 1, a + n + 1);
15+
for (int i = 1; i <= n; i++) {
16+
if ((m -= a[i].second) < 0) {
17+
printf("Case %d: %d\n", T, i - 1);
18+
goto fin;
19+
}
20+
}
21+
printf("Case %d: %d\n", T, n);
22+
fin:;
23+
}
24+
return 0;
25+
}

_gym/102055/D.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include <algorithm>
2+
#include <cstdio>
3+
#include <cstdlib>
4+
#include <cstring>

0 commit comments

Comments
 (0)