0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-14 07:18:47 +00:00

Compare commits

..

No commits in common. "6654bdef0996f15b078fd6e38c9fffff514ecba3" and "ac163af77c8201a99a9284fa40077eb5b14580f3" have entirely different histories.

34 changed files with 0 additions and 223 deletions

View File

@ -1,81 +0,0 @@
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 50005;
const int hash = 1000003;
const int mod = 1e9 + 7;
int k, n, a[15][N], s[15][N], e[N], next[15][N], ans;
std::vector<int> nums, p[N];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> k >> n;
for (int i = 1; i <= k; i++) {
std::string str;
cin >> str;
for (int j = 1; j <= n; j++) {
a[i][j] = str[j - 1] == '(' ? 1 : -1;
s[i][j] = s[i][j - 1] + a[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
e[i] = ((static_cast<long long>(e[i]) * hash % mod + s[j][i]) % mod + mod) % mod;
}
nums.push_back(e[i]);
}
std::sort(nums.begin(), nums.end());
nums.erase(std::unique(nums.begin(), nums.end()), nums.end());
p[0].emplace_back(0);
for (int i = 1; i <= n; i++) {
e[i] = std::lower_bound(nums.begin(), nums.end(), e[i]) - nums.begin() + 1;
p[e[i]].emplace_back(i);
}
for (int i = 1; i <= k; i++) {
std::stack<int> st;
for (int j = 1; j <= n; j++) {
while (!st.empty() && s[i][st.top()] > s[i][j]) {
next[i][st.top()] = j;
st.pop();
}
st.emplace(j);
}
}
for (int i = 1; i <= n; i++) {
int min = n;
for (int j = 1; j <= k; j++) {
if (next[j][i]) {
min = std::min(min, next[j][i]);
}
}
ans += std::upper_bound(p[e[i]].begin(), p[e[i]].end(), min) - std::lower_bound(p[e[i]].begin(), p[e[i]].end(), i + 1);
}
cout << ans << endl;
return 0;
}

BIN
BZOJ/3015/data/1.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/1.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/10.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/10.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/11.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/11.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/12.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/12.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/13.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/13.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/14.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/14.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/15.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/15.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/16.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/16.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/2.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/2.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/3.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/3.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/4.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/4.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/5.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/5.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/6.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/6.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/7.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/7.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/8.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/8.out (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/9.in (Stored with Git LFS)

Binary file not shown.

BIN
BZOJ/3015/data/9.out (Stored with Git LFS)

Binary file not shown.

View File

@ -1,46 +0,0 @@
#include <iostream>
#include <string>
#include <unordered_map>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e6 + 5;
int n;
long long ans;
std::string s[N];
std::unordered_map<std::string, int> map;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1, _; i <= n; i++) {
cin >> _ >> s[i];
map[s[i]]++;
}
for (int i = 1; i <= n; i++) {
std::string str, str1(s[i]);
str.reserve(s[i].size());
str1.reserve(s[i].size() << 1);
for (char c : s[i]) {
str.push_back(c);
str1.push_back(c);
if (map.count(str) && str1 == str + s[i]) {
ans += static_cast<long long>(map[str]) * 2;
}
}
}
cout << ans - n << endl;
return 0;
}