QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#251890 | #7700. Split Decisions | funnuf | WA | 39ms | 4008kb | C++14 | 2.6kb | 2023-11-15 12:04:50 | 2023-11-15 12:04:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i, j, k) for (ll i = j; i <= k; ++i)
#define per(i, j, k) for (ll i = j; i >= k; --i)
#define closeSync \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define pii pair<ll, ll>
#define fi first
#define se second
const ll INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
void solve() {
int n;
cin >> n;
vector<vector<string>> vec(21);
rep(i, 1, n) {
string s;
cin >> s;
int len = s.length();
vec[len].push_back(s);
}
map<pair<string, string>, int> mp;
for (int len = 3; len <= 20; ++len) {
int siz = vec[len].size();
if (siz < 2) {
continue;
}
for (int i = 0; i < siz; ++i) {
for (int j = i + 1; j < siz; ++j) {
vector<int> dif;
for (int k = 0; k < len; ++k) {
if (vec[len][i][k] != vec[len][j][k]) {
dif.push_back(k);
}
}
if (dif.size() == 2 && dif[1] - dif[0] == 1) {
string a, b;
a += vec[len][i][dif[0]];
a += vec[len][i][dif[1]];
b += vec[len][j][dif[0]];
b += vec[len][j][dif[1]];
mp[make_pair(a, b)]++;
mp[make_pair(b, a)]++;
} else if (dif.size() == 1) {
int pos = dif[0];
if (pos != 0) {
string a, b;
a += vec[len][i][pos - 1];
a += vec[len][i][pos];
b += vec[len][j][pos - 1];
b += vec[len][j][pos];
mp[make_pair(a, b)]++;
mp[make_pair(b, a)]++;
}
if (pos != len - 1) {
string a, b;
a += vec[len][i][pos];
a += vec[len][i][pos + 1];
b += vec[len][j][pos];
b += vec[len][j][pos + 1];
mp[make_pair(a, b)]++;
mp[make_pair(b, a)]++;
}
}
}
}
}
int ans = 0;
for (auto it : mp) {
if (it.second == 1)
ans++;
}
cout << ans / 2;
}
int main() {
closeSync;
// int T;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: 3600kb
input:
5 CELL GULL GUSH HALL HASH
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 39ms
memory: 4008kb
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:
809
result:
wrong answer 1st lines differ - expected: '621', found: '809'