QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#359526#7700. Split Decisionswarner1129#WA 40ms3932kbC++202.2kb2024-03-20 18:50:392024-03-20 18:50:39

Judging History

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

  • [2024-03-20 18:50:39]
  • 评测
  • 测评结果:WA
  • 用时:40ms
  • 内存:3932kb
  • [2024-03-20 18:50:39]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

template <ranges::range T,
          class = enable_if_t<!is_convertible_v<T, string_view>>>
istream &operator>>(istream &s, T &&v) {
    for (auto &&x : v)
        s >> x;
    return s;
}
template <ranges::range T,
          class = enable_if_t<!is_convertible_v<T, string_view>>>
ostream &operator<<(ostream &s, T &&v) {
    for (auto &&x : v)
        s << x << ' ';
    return s;
}

#ifdef LOCAL
template <class... T> void dbg(T... x) {
    char e{};
    ((cerr << e << x, e = ' '), ...);
}
#define debug(x...) dbg(#x, '=', x, '\n')
#else
#define debug(...) ((void)0)
#endif

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second

template <class T> inline constexpr T inf = numeric_limits<T>::max() / 2;
template <class T> bool chmin(T &a, T b) { return (b < a and (a = b, true)); }
template <class T> bool chmax(T &a, T b) { return (a < b and (a = b, true)); }

using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;

// constexpr i64 mod = 1e9 + 7;

void solve() {
    int n;
    cin >> n;

    vector<string> S(n);
    cin >> S;

    int ans = 0;
    for (int k = 0; k + 1 < 20; k++) {
        map<pair<string, int>, int> cnt;
        
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++) {
                if (S[i].size() != S[j].size() or k + 1 >= S[i].size())
                    continue;

                if (S[i].substr(0, k) == S[j].substr(0, k) and S[i].substr(k + 2) == S[j].substr(k + 2)) {
                    string a = S[i].substr(k, 2);
                    string b = S[j].substr(k, 2);
                    if (a[0] != b[0] and a[1] != b[1]) {
                        cnt[{a + b, S[i].size()}]++;
                    }
                }
            }
        for (auto &[a, b] : cnt)
            if (b == 1) {
                ans++;
            }
    }

    cout << ans << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(false);
    cin.exceptions(cin.failbit);

    int t = 1;
    // cin >> t;

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3676kb

input:

5
CELL
GULL
GUSH
HALL
HASH

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 40ms
memory: 3932kb

input:

1000
ABSALOM
ACRATIA
AKHOOND
ALIBAMU
AMUSIVE
AGONIZE
ACOCOTL
ACTINON
ABELITE
ADVISAL
ALBETAD
AMAKEBE
ANASAZI
AMUCHCO
ADDENDA
AMESITE
ALIENEE
ADRENIN
ACERATE
AKERITE
AMPELIS
ABABDEH
ALCIDAE
AGRANIA
ALASTER
AMERISM
AMILOUN
AMYGDAL
ALUNDUM
ACHOLIC
ALTHAEA
ACIDIFY
AMNESTY
ABBOTCY
AMBALAM
AMENITY
AEOLISM...

output:

700

result:

wrong answer 1st lines differ - expected: '621', found: '700'