codeforces 1070 H. BerOS File Suggestion map
題目:
傳送門
思路:
將每一個字串的每一個子串都映射出來,最後詢問的時候輸出結果即可。
程式碼如下:
#include <bits/stdc++.h> using namespace std; int n,q; map<string,string>m1; map<string,int>m2; int main() { string s; scanf("%d",&n); while (n--) { cin>>s; int len=s.size(); map<string,int>rep; for (int i=1;i<=len;i++) { for (int j=0;j+i<=len;j++) { string t=s.substr(j,i); if(rep[t]==0) { rep[t]=1; m1[t]=s; m2[t]++; } } } } scanf("%d",&q); while (q--) { string s; cin>>s; if(m2[s]==0) cout<<0<<" "<<"-"<<endl; else cout<<m2[s]<<" "<<m1[s]<<endl; } return 0; }
相關推薦
codeforces 1070 H. BerOS File Suggestion map
題目:傳送門 思路: 將每一個字串的每一個子串都映射出來,最後詢問的時候輸出結果即可。 程式碼如下: #include <bits/stdc++.h> using namespace std; int n,q; map<string,string>
Codeforce 2018-2019 ICPC Southern Subregional Contest H.BerOS File Suggestion
題意: 給你N個長度不超過8個字元的字串,然後進行Q次查詢,對於每次查詢的字串Sq,輸出含有Sq的字串的個數和其中一個字串,如果沒有則輸出0和-1。 樣例輸入: 4 test contests test. .test 6 ts . st. .test contes.
BerOS File Suggestion (Codeforces 1070H)
題目連結: http://codeforces.com/problemset/problem/1070/H 思路:直接找的話,會時間超限,所以可以用map把上面輸入的串的所有字串都記下來,用兩個map,一個記錄有幾個串有匹配的,一個記錄匹配的串是哪個。 #include<c
Codeforces 1070H - BerOS File Suggestion 暴力 (2018-2019 ICPC, NEERC)
CF: *1600 題意:給定n個字串(長度最大8),q個查詢,問上述n個串中有多少個串的子串是這個查詢的串,任意輸出一個原串 思路:直接暴力 #include<bits/stdc++.h> using namespace std;
BerOS File Suggestion (Codeforces 1070H)
思路:直接找的話,會時間超限,所以可以用map把上面輸入的串的所有字串都記下來,用兩個map,一個記錄有幾個串有匹配的,一個記錄匹配的串是哪個。 #include<cstdio> #include<iostream> #include <s
[codeforces1070H]BerOS File Suggestion
time limit per test : 3 seconds memory limit per test : 256 megabytes Polycarp is working on a new operating system called BerOS. He asks you
BerOS File Suggestion
Description Polycarp is working on a new operating system called BerOS. He asks you to help with implementation of a file suggestio
編譯依賴於React Native0.46.4的React Native IOS工程時,出現錯誤“fatal error: 'React/RCTEventEmitter.h' file not found”
問題 clear solution str ack fat navi parallel avi 我的環境: WebStorm 2017.2Build #WS-172.3317.70, built on July 14, 2017 JRE: 1.8.0_152-release
BerOS file system
least call ash res mali not ssi nice possible The new operating system BerOS has a nice feature. It is possible to use any number of
ReactNative Ios報出 'React/RCTBundleURLProvider.h' file not found錯誤
我在建立react-native專案時 npm了一個第三方庫 結果一開啟 xcode 竟然報錯 React/RCTBundleURLProvider.h' file not found; 然後 我試了各種網上的方法試了一遍, 還是不行 就在我要放棄的時候 ,突然想到把網上
'React/RCTBundleURLProvider.h' file not found
'React/RCTBundleURLProvider.h' file not found 新建RN專案時在iOS端用xcode跑時有時會遇到 'React/RCTBundleURLProvider.h' file not found 錯誤,遇到這種錯誤一般有一下幾種情況: 1. 沒有執行
轉 react-native 日常報錯 'config.h' file not found 解決 方法
cd node_modules/react-native/third-party/glog-0.3.4 ../../scripts/ios-configure-glog.sh product -> clean build folder 其實執行 .sh 命令
Xcode 10: third-party: 'config.h' file not found
使用 RN 的專案,XCode 10 ,編譯時候會報這個錯。 原因: 新XCode 執行某指令碼的時候,相對路徑找錯了 # 本指令碼的目的是解決升級了 xcode 10 之後,編譯時報錯 找不到 config.h 的問題 cd ./node_modules
codeforces 1070 F. Debate 貪心
題目: 傳送門 題意: 有兩個人A,B,參加票選,給出投票人的結果和投票價值,求最大的投票價值,要求最小的票選人的票數一定為人數的一半或以上。 思路: 投票為11結果的人一定會被全選上,而從投01和投10的人中選最小的人數,11和01和10中最小的加起來就是最小票選人數。
codeforce1046 H. Palindrome Pairs 二進位制+map
求組成迴文串的對數(字元任意排列) #include<bits/stdc++.h> using namespace std; const int MAXN=1e6+5; int n,l; char s[MAXN]; map<long long,long
解決clang"fatal error: 'stdio.h' file not found"問題
先看一下下面這個”hello world”程式 #include <stdio.h> int main(void) { printf("hello!\n"); return 0; } 在Windows下使用”gcc test.c”編譯這個程式不會出現
codeforce 1070 H
題意:tr1中有多少str2的子串。輸出為個數+任意一個str1串。如果沒有則輸出“0 -”。 思路:暴力肯定不行,算下來時間複雜度的話O(5e8),鐵定超時。所以得先預處理一下。在網上找題解發現都是用map進行子串的預處理,而且用了一個string非常好的內建
Codeforces 730G. Car Repair Shop 【map】
Polycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair shop is very small and only one c
CodeForces 1070 M. Algoland and Berland
連結: link 題意: 平面上有 aaa 個紅色點和 bbb 個藍色點,沒有三點共線,紅藍點之間可以連邊,求一棵生成樹,使得第 iii 個藍點的度數恰好為 rir_iri ,並且生成樹的連邊在平面上不會在除了端點的地方相交。 保證 ∑ri=a+b−1,1≤r
python安裝軟體出現錯誤 fatal error: 'libxml/xmlversion.h' file not found
1、python2 出現問題的解決辦法: sudo C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimula