Submission #3622829


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/








int N; string A[30101]; int M[301010];
using T = tuple<int, int, int, int>;
//---------------------------------------------------------------------------------------------------
int encode(char c) {
    if ('A' <= c and c <= 'Z') return c - 'A';
    return c - 'a' + 26;
}
char decode(int i) {
    if (i < 26) return char('A' + i);
    return char('a' + i - 26);
}
//---------------------------------------------------------------------------------------------------
int cnt[52], vis[52];
void _main() {
    cin >> N;
    rep(i, 0, N) {
        cin >> A[i];
        M[i] = A[i].length();
        fore(c, A[i]) c = encode(c);
    }

    T ans = make_tuple(inf, inf, inf, inf);
    rep(i, 0, 52) rep(j, 0, 52) {
        rep(n, 0, N) {
            int idx = 0;
            while (idx < M[n] and A[n][idx] != i) idx++;
            idx++;
            while (idx < M[n] and A[n][idx] != j) idx++;
            idx++;
            rep(m, idx, M[n]) vis[A[n][m]] = 1;

            rep(m, idx, M[n]) if (vis[A[n][m]]) {
                cnt[A[n][m]]++;
                vis[A[n][m]] = 0;
            }
        }
        rep(k, 0, 52) if(cnt[k]) {
            chmin(ans, make_tuple(-cnt[k], i, j, k));
            cnt[k] = 0;
        }
    }

    int ma, i, j, k;
    tie(ma, i, j, k) = ans;
    printf("%c%c%c\n", decode(i), decode(j), decode(k));
}

Submission Info

Submission Time
Task D - Three Letters
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2625 Byte
Status AC
Exec Time 869 ms
Memory 2048 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 15
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All 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 AC 772 ms 2048 KB
02.txt AC 478 ms 640 KB
03.txt AC 548 ms 768 KB
04.txt AC 591 ms 640 KB
05.txt AC 869 ms 640 KB
06.txt AC 599 ms 640 KB
07.txt AC 681 ms 1024 KB
08.txt AC 740 ms 640 KB
09.txt AC 680 ms 1024 KB
10.txt AC 512 ms 768 KB
11.txt AC 778 ms 2048 KB
12.txt AC 791 ms 2048 KB
13.txt AC 778 ms 2048 KB
sample_01.txt AC 2 ms 512 KB
sample_02.txt AC 2 ms 512 KB