QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#105303#5499. Aliasespdstiago#WA 2ms3388kbC++141.5kb2023-05-13 21:32:412023-05-13 21:32:42

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-13 21:32:42]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3388kb
  • [2023-05-13 21:32:41]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

#define mxn 1e5+5
#define fastio ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define endl '\n'
#define INF 0x3f3f3f3f
typedef long long ll;

int solve(){
    int n;
    cin >> n;
    vector<pair<string, string> > v(n+1);

    for(int i=1; i<=n; i++){
        cin >> v[i].first >> v[i].second;
    }
    string num = to_string(n);
    n--;
    int m = (int)num.size();
    int resp=m;
    int ar = 0, br = 0, cr = 0;
    for(int a=0; a<=m; a++){
        for(int b=0; b<=m; b++){
            map<string, int> mapa;
            for(int i=1; i<=n; i++){
                string as = v[i].first.substr(0, min(a, (int)v[i].first.size()));
                string bs = v[i].second.substr(0, min(b, (int)v[i].second.size()));
                mapa[as+bs]++;
            }
            int maior=0;
            for(auto it=mapa.begin(); it!=mapa.end(); it++){
                pair<string, int> agr = *it;
                maior=max(maior, agr.second);
            }
            int best=0;
            maior--;
            if(maior>0){
                string agr = to_string(maior);
                best = (int)agr.size();
            }
            if(a+b+best<=resp){
                resp=a+b+best;
                ar=a, br=b, cr=best;
            }
        }
    }
    cout << ar << " " << br << " " << cr << endl;
    return 0;
}

int main(){
    fastio;

    int t = 1; 
    cin >> t;

    while(t--){
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3388kb

input:

1
11
sven eriksson
erik svensson
sven svensson
erik eriksson
bjorn eriksson
bjorn svensson
bjorn bjornsson
erik bjornsson
sven bjornsson
thor odinsson
odin thorsson

output:

0 0 1

result:

wrong answer Loginy nieunikalne! (test case 1)