RT,非常奇怪的输入输出格式,没道理Too long啊?
评测记录?
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<string>
#include<bitset>
#include<stack>
#include<random>
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
constexpr int MAXN=5e5+10;
#define mpr make_pair
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll A, B, n;
cin >> A >> B >> n;
string context = "", line;
while(cin >> line){
if(line == "*")break;
context += line;
}
unordered_map<string, ll> mp;
ll len = static_cast<ll>(context.size());
for(ll i = 0; i < len; i++){
string tmp = "";
for(ll j = 0; j < 12; j++){
if(i + j >= len)break;
tmp += context.at(i + j);
if(A <= j + 1 && j + 1 <= B){
mp[tmp]++;
}
}
}
vector<pair<string, ll>> a(mp.begin(), mp.end());
sort(a.begin(), a.end(), [&](const pair<string,ll>& a, const pair<string,ll>& b){
if(a.second != b.second)
return a.second > b.second;
if(a.first.size() != b.first.size())
return a.first.size() < b.first.size();
return a.first < b.first;
});
ll cnt = 0, cur = -1, enter = 0;
bool firstline = true, firstcase = true;
for(auto&p:a){
if(cur == p.second){
if(firstcase)firstcase = false;
else cout << ' ';
cout << p.first;
enter++;
if(enter >= 6){
enter = 0;
firstcase = true;
putchar('\n');
}
continue;
}else{
cnt++;
enter = 0;
if(cnt > n)break;
if(firstline)firstline = false;
else putchar('\n');
cur = p.second;
cout << cur << '\n';
cout << p.first;
enter++;
}
}
cout << flush;
return 0;
}