我对这道题目的难度评定也是服了……
查看原帖
我对这道题目的难度评定也是服了……
112917
Eason_AC楼主2021/9/7 17:12

RT,O(n2logn)O(n^2\log n) 的暴力也可以过得去的题目你跟我说是省选/NOI-……

namespace Solution {
    string s, t;
    map<string, int> mp;

    iv Main() {
        int kase = 0;
        while(cin >> s >> t) {
            mp.clear(), kase++;
            if(kase > 1) puts("");
            int lens = s.size(), lent = t.size(), ans = 0;
            F(int, len, 1, lens) F(int, i, 0, lens - len) mp[s.substr(i, len)] |= 1;
            F(int, len, 1, lent) F(int, i, 0, lent - len) mp[t.substr(i, len)] |= 2;
            for(auto x : mp) if(x.se == 3) ans = max(ans, (int)x.fi.size());
            if(!ans) puts("No common sequence.");
            else {
                vector<string> res;
                for(auto x : mp) if((int)x.fi.size() == ans && x.se == 3) res.push_back(x.fi);
                sort(res.begin(), res.end());
                F(int, i, 0, (int)res.size() - 1) cout << res[i] << endl;
            }
        }
        return; 
    }
}
2021/9/7 17:12
加载中...