Help!除了第二个全部Too long at line 2
查看原帖
Help!除了第二个全部Too long at line 2
134593
反手一只MJJ楼主2024/10/4 15:39

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
//template<typename T> T read(T tmp){
//    T x = 0;
//    char g = getchar();
//    bool f = true;
//    while(!isdigit(g)){if(g == '-')f = !f;g = getchar();}
//    while(isdigit(g)){x = (x << 1) + (x << 3) + (g ^ 48);g = getchar();}
//    return f ? x : -x;
//}
//#define rd read(1ll)
//template<typename T> void write(T x){
//    if(x < 0){putchar('-');x = -x;}
//    if(x > 9)write(x / 10);
//    putchar(x % 10 ^ 48);
//}

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;
}
/*
 2 7 50
 01010010010001000111101100001010
 011001111000010010011110010000000
 *
 
 */

2024/10/4 15:39
加载中...