Submission #3623170


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int cnt[52][52][52], last[52][52][52];

int c2i(char c){
    if('A' <= c && c <= 'Z'){
        return c - 'A';
    }else{
        return c - 'a' + 26;
    }
}

char i2c(int i){
    if(0 <= i && i < 26){
        return i + 'A';
    }else{
        return i + 'a' - 26;
    }
}

int main(){
    int N;
    cin >> N;
    string A[30000];
    for(int i=0; i<N; i++) cin >> A[i];

    memset(last, -1, sizeof(last));
    for(int i=0; i<N; i++){
        vector<int> left(52, 0), right(52, 0);
        for(auto c : A[i]) right[c2i(c)]++;
        for(int j=0; j<A[i].size(); j++){
            int n = c2i(A[i][j]);
            right[n]--;
            for(int k1=0; k1<52; k1++){
                for(int k2=0; k2<52; k2++){
                    if(left[k1] && right[k2] && last[k1][n][k2] < i){
                        last[k1][n][k2] = i;
                        cnt[k1][n][k2]++;
                    }
                }
            }
            left[n]++;
        }
    }
    int opt = -1;
    string ans = "AAA";
    for(int i=0; i<52; i++){
        for(int j=0; j<52; j++){
            for(int k=0; k<52; k++){
                if(opt < cnt[i][j][k]){
                    opt = cnt[i][j][k];
                    ans[0] = i2c(i);
                    ans[1] = i2c(j);
                    ans[2] = i2c(k);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Three Letters
User betrue12
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1492 Byte
Status
Exec Time 468 ms
Memory 2944 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
All 500 / 500 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
01.txt 277 ms 2944 KB
02.txt 373 ms 1792 KB
03.txt 292 ms 1920 KB
04.txt 367 ms 1792 KB
05.txt 468 ms 1664 KB
06.txt 405 ms 1664 KB
07.txt 278 ms 2176 KB
08.txt 420 ms 1664 KB
09.txt 278 ms 2176 KB
10.txt 301 ms 1792 KB
11.txt 278 ms 2944 KB
12.txt 277 ms 2944 KB
13.txt 277 ms 2944 KB
sample_01.txt 2 ms 1024 KB
sample_02.txt 2 ms 1024 KB