QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#710149#7700. Split DecisionsbecaidoAC ✓12ms28684kbC++201.7kb2024-11-04 18:50:542024-11-04 18:50:54

Judging History

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

  • [2024-11-04 18:50:54]
  • 评测
  • 测评结果:AC
  • 用时:12ms
  • 内存:28684kb
  • [2024-11-04 18:50:54]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout (T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);}
#else
#define debug(...) 7122
#endif

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 1505;
const int MAX = 26 * 26 * 26 * 26 + 5;

int n, ans;
vector<string> v[21];
string s[SIZE];
int cnt[21][MAX];

void solve() {
    cin >> n;
    FOR (i, 1, n) {
        cin >> s[i];
        v[s[i].size()].pb(s[i]);
    }
    FOR (len, 1, 20) if (v[len].size()) {
        n = v[len].size();
        FOR (i, 0, n - 1) s[i + 1] = v[len][i];
        FOR (i, 1, n) FOR (j, i + 1, n) {
            int p = -1, c = 0;
            FOR (k, 0, s[i].size() - 1) if (s[i][k] != s[j][k]) {
                c++;
                p = k;
            }
            if (c == 2 && s[i][p - 1] != s[j][p - 1]) {
                string t;
                t += min(s[i].substr(p - 1, 2), s[j].substr(p - 1, 2));
                t += max(s[i].substr(p - 1, 2), s[j].substr(p - 1, 2));
                int val = 0;
                for (char c : t) val = 26 * val + c - 'A';
                cnt[p - 1][val]++;
            }
        }
        FOR (i, 0, s[1].size() - 1) FOR (j, 0, MAX - 1) {
            ans += (cnt[i][j] == 1);
            cnt[i][j] = 0;
        }
    }
    cout << ans << '\n';
}

int main() {
    Waimai;
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
CELL
GULL
GUSH
HALL
HASH

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 3ms
memory: 16184kb

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:

621

result:

ok single line: '621'

Test #3:

score: 0
Accepted
time: 4ms
memory: 16176kb

input:

14
ALTO
AFRO
AGENT
CAMP
CHEAP
CHESS
CLAP
CORSAGE
COURAGE
EXTINCT
EXTRACT
SCENT
STEEP
CHUMP

output:

7

result:

ok single line: '7'

Test #4:

score: 0
Accepted
time: 4ms
memory: 10856kb

input:

4
ABCD
AEFD
AGHD
AIJD

output:

6

result:

ok single line: '6'

Test #5:

score: 0
Accepted
time: 0ms
memory: 12612kb

input:

3
ABABA
AABBA
ABBAA

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 0ms
memory: 12544kb

input:

3
AAAAA
ABBAA
AABBA

output:

2

result:

ok single line: '2'

Test #7:

score: 0
Accepted
time: 3ms
memory: 10760kb

input:

8
ABBA
ACCA
AABB
AACC
DBBD
DCCD
EEBB
EECC

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 0ms
memory: 11012kb

input:

6
ABBA
ACCA
AABB
AACC
DBBD
DCCD

output:

1

result:

ok single line: '1'

Test #9:

score: 0
Accepted
time: 0ms
memory: 10816kb

input:

4
ABBA
ACCA
AABB
AACC

output:

2

result:

ok single line: '2'

Test #10:

score: 0
Accepted
time: 0ms
memory: 12544kb

input:

4
ABBA
ACCA
ABBAA
ACCAA

output:

2

result:

ok single line: '2'

Test #11:

score: 0
Accepted
time: 7ms
memory: 21468kb

input:

100
CCBAEADDE
CABCDE
EDBCBEC
BAEE
EDADBBEBA
BCAEC
EABCE
ADECB
BEACCDECB
DEDE
BADDDAE
BBBADBAED
CDEBBC
CAADCDEE
EECD
EAAAABA
EAADAAC
DDBACADDB
DCCCCCB
AADEDBC
ACBAACBDB
CDAAACCBC
EEDCB
CCEEBCEEE
AEAABE
BEDEAAACB
DAECDB
CACBBEB
ABEBED
ECEDAEE
EDCEBBBADB
BEACE
EDBAADAE
AABADC
EBAA
CDED
ADABEA
CBACCBC
A...

output:

4

result:

ok single line: '4'

Test #12:

score: 0
Accepted
time: 0ms
memory: 21756kb

input:

20
AABCC
BADCCCBA
ADCEECBB
DAEEDCB
EAAC
CDCEAEADC
ADBBCDBBCA
BBCABBECAE
CEBAEAEB
CCAAB
EEDADEEB
EADA
CBBEA
ABBDDCC
BABADDA
AEBDBCDBAD
ACCCDDEAB
AEDADEBA
BCDED
DBAB

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 4ms
memory: 21488kb

input:

250
AEGDGEAB
GGEG
BEEFFEDDF
BBCA
EGBC
BABFDDAFA
GGACGCCCBD
DBFBF
DDDCDG
FAGAED
FFBBAFCBF
EAAEEEAAB
GDAGBA
AEBFFAD
EGBGBBAAA
FFGEGC
DDBGAGADB
EDEBB
EABGBGF
EFBEDBGD
BFGGD
CDGB
CCEGABGFGB
ACEFGEEBA
GDAC
GCEDAFBBA
BFEFAFBGAA
AEGD
GGEACB
CEFBGFAA
GAADFG
ADBD
EABBGA
FFFCE
FDEGGFAAD
AEEFBEE
DCDCFFBD
ACFDC...

output:

39

result:

ok single line: '39'

Test #14:

score: 0
Accepted
time: 8ms
memory: 21460kb

input:

30
CEBCBABB
EADCEC
CADEDDCBBB
CAAE
BBDCCEBEEA
DBABADCAAA
ACCDCECE
CBBEDCCECA
EACDDBB
ECCCCDB
BCDBDAECA
DABD
BECDAEE
ACCBEBEA
BBBDCBEAE
DACCEDB
BEEDBDB
ABBAACCDAA
DCBEB
EECB
ADEE
ADEBCEDCBB
ADADAECE
DBCBD
BBBE
AEDEA
AEAADD
EAAEBE
EBBA
ABCA

output:

0

result:

ok single line: '0'

Test #15:

score: 0
Accepted
time: 3ms
memory: 21520kb

input:

40
CABBD
BAABEA
ADAEABCD
BDCDEECACB
DBABEB
ECDBAAEE
EDABABCEAB
DBEADCADAC
BBEBADBCC
AADEBBCB
CBAAACBEAE
BDAC
DCDCACD
BACABDBCCA
CEBEEEDDB
BACC
AEABCAAC
ABECDDDDBC
CADECB
EAAAAAAE
BDBECEEDBC
AECB
CABAECCE
BCBAA
DCCEBB
ECCBEEC
EECBEABE
CDEAD
DBABA
BDAAED
BCDEBCADEC
BBCDBCAB
EBDAE
DEEACCB
ECACDAA
BCBCC...

output:

1

result:

ok single line: '1'

Test #16:

score: 0
Accepted
time: 0ms
memory: 9228kb

input:

7
ABC
AEF
BAB
BEF
ABA
ACA
AAB

output:

7

result:

ok single line: '7'

Test #17:

score: 0
Accepted
time: 7ms
memory: 28684kb

input:

642
AARON
ABANDONED
ABERDEEN
ABILITIES
ABILITY
ABLE
ABORIGINAL
ABORTION
ABOUT
ABOVE
ABRAHAM
ABROAD
ABSENCE
ABSENT
ABSOLUTE
ABSOLUTELY
ABSORPTION
ABSTRACT
ABSTRACTS
ABUSE
ACADEMIC
ACADEMICS
ACADEMY
ACCENT
ACCEPT
ACCEPTABLE
ACCEPTANCE
ACCEPTED
ACCEPTING
ACCEPTS
ACCESS
ACCESSED
ACCESSIBILITY
ACCESSIBLE...

output:

240

result:

ok single line: '240'

Test #18:

score: 0
Accepted
time: 12ms
memory: 21640kb

input:

1499
AAAAAAAAAA
AAAAABAAAA
AAAAACAAAA
AAAAADAAAA
AAAAAEAAAA
AAAAAFAAAA
AAAAAGAAAA
AAAAAHAAAA
AAAAAIAAAA
AAAAAJAAAA
AAAAAKAAAA
AAAAALAAAA
AAAAAMAAAA
AAAAANAAAA
AAAAAOAAAA
AAAAAPAAAA
AAAAAQAAAA
AAAAARAAAA
AAAAASAAAA
AAAAATAAAA
AAAAAUAAAA
AAAAAVAAAA
AAAAAWAAAA
AAAAAXAAAA
AAAAAYAAAA
AAAAAZAAAA
AAAABAAAA...

output:

211250

result:

ok single line: '211250'