Codeforces 1070H - BerOS File Suggestion 暴力 (2018-2019 ICPC, NEERC)
CF: *1600
題意:給定n個字串(長度最大8),q個查詢,問上述n個串中有多少個串的子串是這個查詢的串,任意輸出一個原串
思路:直接暴力
#include<bits/stdc++.h>
using namespace std;
#define out fflush(stdout);
#define fast ios::sync_with_stdio(0),cin.tie(0);
#define FI first
#define SE second
typedef long long ll;
typedef pair<int,int> P;
const int maxn = 2e5 + 7;
const int INF = 0x3f3f3f3f;
const ll mod = 998244353;
int n, q;
map<string, int> mp;
map<string, bool> vis;
map<string, string> ans;
int main() {fast;
cin >> n;
string s;
for(int i = 1; i <= n; ++i) {
cin >> s;
vis.clear();
for(int l = 0; l < s.size(); ++l) {
string t;
for(int r = l; r < s.size(); ++r) {
t.push_back(s[r]);
if(!vis[t]) {
mp[t]++;
ans[t] = s;
vis[t] = true;
}
}
}
}
cin >> q;
for(int i = 1; i <= q; ++i) {
cin >> s;
int cnt = mp[s];
if(cnt) {
cout << cnt << " " << ans[s] << endl;
}
else {
cout << "0 -" << endl;
}
}
return 0;
}
相關文章
- Codeforces 1070C - Cloud Computing 思路+線段樹+貪心 (2018-2019 ICPC, NEERC)Cloud
- Codeforces ICPC那場
- 2018-2019 ACM-ICPC, Asia Seoul Regional Contest——A - CircuitsACMUI
- 2018-2019 ACM-ICPC, China Multi-Provincial Collegiate Programming ContestACM
- codeforces 1216E1(數學+暴力)
- 2019-2020 ICPC, NERC, Northern Eurasia Finals E. Elections (暴力&貪心)
- 2020-2021 ICPC NERC (NEERC), North-Western Russia Regional Contest (Northern Subregionals) E(離散化+尤拉回路)
- NEERC2014題解
- Codeforces Round #537 (Div. 2)B. Average Superhero Gang Power (貪心+暴力)
- BZOJ2647 : [Neerc2011]Journey
- 搜尋欄獲取百度suggestion
- P6970 [NEERC2016] Game on GraphGAM
- Suggestion: use a compatible library with a minSdk of at most 16, or increase this project's minSdkProject
- P6123 [NEERC2016] Hard Refactoring 題解
- 2021 ICPC 南京
- 2023 ICPC 南京
- 2023 ICPC合肥
- [2017 ICPC Nanning] Rake It InNaN
- ICPC 成都遊記
- 如何讓 Visual Studio Code 裡顯示 Cypress 的 intelligent code suggestionIntel
- 暴力破解
- Codeforces
- 『杭電1940』ICPC Scoreboard
- 2023ICPC 瀋陽
- 2020 ICPC 上海賽區
- C++暴力指南C++
- 什麼是暴力破解?暴力破解的方法有哪些?
- 南洋理工:研究發現暴力遊戲與暴力行為無關遊戲
- cat > file << EOF 與 cat > file << -
- ICPC2023 杭州 題解
- The 2024 ICPC Asia Nanjing Regional ContestNaN
- The 2021 ICPC Asia Shenyang Regional Contest
- The 2023 ICPC Asia Macau Regional ContestMac
- ICPC2023瀋陽K
- The 2022 ICPC Asia Nanjing Regional ContestNaN
- The 2022 ICPC Asia Xian Regional Contest
- 2024.11.2 2024ICPC成都站
- CodeForces 1307