QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#322754 | #4828. Four Plus Four | Skyan | 0 | 0ms | 0kb | C++23 | 2.6kb | 2024-02-07 16:58:52 | 2024-02-07 16:58:52 |
answer
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
string a[10005], b[10005], s[30005], t[4005];
int c[30005][26], d[4005][26], dd[4005][4005], p[4005];
vector<int> g[30005], res[30005];
map<string, int> m;
bool check(int x, int y) {
for (int i = 0; i < 26; i++) {
if (c[x][i] < d[x][i]) {
return false;
}
}
return true;
}
bool cmp(int x, int y) {
return p[x] > p[y];
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
string ss;
cin >> ss;
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (ss == "keys") cin >> b[i];
}
int x, y;
cin >> x;
for (int i = 1; i <= x; i++) {
cin >> s[i];
m[s[i]] = i;
for (char w : s[i]) {
c[i][w - 'a']++;
}
}
cin >> y;
for (int i = 1; i <= y; i++) {
cin >> t[i];
m[t[i]] = i;
for (char w : t[i]) {
d[i][w - 'a']++;
}
}
vector<pair<int, int>> v;
for (int i = 1; i <= x; i++) {
for (int j = 1; j <= y; j++) {
if (check(i, j) == true) {
g[i].push_back(j);
g[i].push_back(j);
g[i].push_back(j);
}
}
if (g[i].size() >= 9) {
v.push_back({g[i].size(), i});
}
}
sort(v.begin(), v.end());
for (auto w : v) {
sort(g[w.second].begin(), g[w.second].end(), cmp);
for (int x : g[w.second]) {
int flag = 0;
for (int xx : res[w.second]) {
if (dd[xx][x] != 0) {
flag = 1;
break;
}
}
if (flag == 0) res[w.second].push_back(x);
if (res[w.second].size() == 3) {
cout << s[w.second] << " " << 1234 << '\n';
break;
}
}
for (int i = 0; i < 3; i++) {
for (int j = i + 1; j < 3; j++) {
dd[res[w.second][i]][res[w.second][j]] = w.second;
dd[res[w.second][j]][res[w.second][i]] = w.second;
p[res[w.second][i]]--;
p[res[w.second][j]]--;
}
}
}
for (int i = 1; i <= n; i++) {
if (ss == "password") {
int h = m[a[i]];
for (auto w : res[h]) {
cout << t[w] << " ";
}
}
else {
cout << s[dd[m[a[i]]][m[b[i]]]];
}
cout << '\n';
}
}
详细
Test #1:
score: 0
Wrong Answer on the first run
input:
password 2 password couthier 28558 aardvark aardwolf aasvogel abacuses abalones abampere abandons abapical abasedly abashing abatable abatises abattoir abbacies abbatial abbesses abdicate abdomens abdomina abducens abducent abducing abducted abductee abductor abelmosk aberrant abetment abettals abet...
output:
abasedly 1234 abducent 1234 absently 1234 acanthus 1234 acceptor 1234 afebrile 1234 aircrews 1234 ambushed 1234 amenders 1234 annulets 1234 antilife 1234 argental 1234 asthenia 1234 asthenic 1234 atheroma 1234 baldrick 1234 balkline 1234 bankings 1234 barreled 1234 beclowns 1234 becudgel 1234 bedmak...
input:
output:
result:
wrong answer abasedly is not in the royal dictionary