S+1 DP1
A. 多重背包问题 II
用优先队列维护可以做到n2的时间复杂度1234567891011121314151617181920212223242526272829303132333435363738signed main(){ IOS; // solve(); // return 0; int n, m; cin >> n >> m; //cout << n << ' ' << m << endl; for (int i = 1; i <= n; i++) { int v, w, s; cin >> v >> w >> s; //s = min(s, m / v); deque<int> q; //cout << "SS : " << v << ...
ABC basket
ABC375D123456789101112131415161718192021222324252627const int mod = 998244353;int mypow(int a, int b) { int res = 1; while (b) { if (b & 1) { res *= a; res %= mod; } b >>= 1; a *= a; a %= mod; } return res;}signed main(){ IOS; int n; cin >> n; int len = to_string(n).size(); int b = mypow(10, len); int res = n % mod * (mypow(b, n) - 1) % mod * (mypow(b - 1, mod ...
abc 374
A12345678910111213141516signed main(){ IOS; string a; cin >> a; int n = a.size(); if (a[n - 3] == 's' && a[n - 2] == 'a' && a[n - 1] == 'n') { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0;}
B12345678910111213141516171819signed main() { IOS; string a; string b; cin >> a >> b; ...
abc 373
A1234567891011121314signed main() { IOS; int ans = 0; for (int i = 1; i <= 12; i++) { string a; cin >> a; if (a.size() == i) { ans++; } } cout << ans << endl; return 0;}
B12345678910111213141516signed main() { IOS; string a; cin >> a; int ans = 0; vector<int> b(30); for (int i = 1; i <= a.size(); i++) { b[a[i] - 'A'] = i; } ...
abc372
A123456789101112signed main() { IOS; string a; cin >> a; for (int i = 0; i < a.size(); i++) { if (a[i] != '.') { cout << a[i]; } } return 0;}
B
普普通通的三进制
123456789101112131415161718192021222324252627282930signed main() { IOS; int x; cin >> x; int tmp = x; int tot = 0; int res = 0; while (x) { int idx = x % 3; while (idx--) { ...
String text
nowcode 151651234567891011121314151617181920212223242526272829303132333435363738394041void solve() { string s; cin >> s; int n = s.size(); s = " " + s; vector<int> nxt(n + 1); for (int i = 2; i <= n; i++) { nxt[i] = nxt[i - 1]; while (nxt[i] && s[nxt[i] + 1] != s[i]) { nxt[i] = nxt[nxt[i]]; } nxt[i] += (s[nxt[i] + 1] == s[i]); } int cnt = count(nxt.begin() + 1, nxt.end(), nxt[ ...
abc371
A
大的加1,第二的在中间
1234567891011121314151617181920212223242526signed main() { IOS; int tmp[3][2] = {{1, 2}, {1, 3}, {2, 3}}; vector<int> v(4, 0); for (int i = 0; i < 3; i++) { int op; char x; cin >> x; if (x == '<') { op = 1; } else { op = 0; } v[tmp[i][op]]++; } for (int i = 1; i <= 3; i++) { // ...
2023 ICPC HEFEI
C 回文自动机
将原字符串复制一遍,防止重复,结尾大于 n nn 的才加入cnt中
之后就是回文自动机的板子123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133int ans = 0;/*---------------回文自动机PAM---------------- 传入字符串下标从0开始- 本质不同的回文子串个数- 所有回文子串个数- 每种回文串出现的次数 cnt(需要get_cnt)- 每种回文串的长度 len- 以下标 i 为结尾的回文串的个数 sed- 每个 ...