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
- 2016-2017 ACM-ICPC, NEERC, Southern Subregional ContestACM
- 2016-2017 ACM-ICPC, NEERC, Northern Subregional ContestACM
- 2017-2018 ACM-ICPC, NEERC, Southern Subregional ContestACM
- 2017-2018 ACM-ICPC, NEERC, Northern Subregional ContestACM
- Codeforces 114A-Cifera(暴力)
- 【暴力】codeforces 838A Binary BlocksBloC
- 2016-2017 ACM-ICPC, NEERC, Moscow Subregional ContestACM
- 2017-2018 ACM-ICPC, NEERC, Moscow Subregional ContestACM
- 2018-2019 ACM-ICPC, Asia Seoul Regional Contest——A - CircuitsACMUI
- Codeforces Round #336 (Div. 2) B 暴力
- codeforces 1216E1(數學+暴力)
- Codeforces 626D Jerry's Protest(暴力列舉+概率)
- 2018-2019 ACM-ICPC, China Multi-Provincial Collegiate Programming ContestACM
- 2020-2021 ICPC NERC (NEERC), North-Western Russia Regional Contest (Northern Subregionals) E(離散化+尤拉回路)
- Codeforces Round #537 (Div. 2)B. Average Superhero Gang Power (貪心+暴力)
- NEERC2014題解
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) B 暴力
- Suggestion(搜尋建議)產品和技術
- ICPC 成都遊記
- Codeforces 617E XOR and Favorite Number (區間異或和 莫隊演算法 分塊暴力)演算法
- 暴力破解
- 2021 ICPC 南京
- api暴力獲取API
- C++暴力指南C++
- 2023 ICPC合肥
- 2023 ICPC 南京
- 南洋理工:研究發現暴力遊戲與暴力行為無關遊戲
- 什麼是暴力破解?暴力破解的方法有哪些?
- NEERC 2015 Southern Subregional G Hiring 樹狀陣列陣列
- [2017 ICPC Nanning] Rake It InNaN
- 暴力破解測試
- kali暴力破解教程
- [暴力 Trick] 根號分治
- Android studio Suggestion: use tools:overrideLibrary=”jp.wasabeef.blurry” to force usageAndroidIDE
- Codeforces
- 快手嚴打網路暴力:整治網路暴力不能一刀切
- ACM ICPC Vietnam National Second RoundACM