QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#244836 | #7686. The Phantom Menace | ckiseki# | WA | 308ms | 3448kb | C++20 | 2.8kb | 2023-11-09 16:25:16 | 2023-11-09 16:25:17 |
Judging History
你现在查看的是最新测评结果
- [2024-10-08 14:11:03]
- hack成功,自动添加数据
- (/hack/941)
- [2024-10-08 10:05:28]
- hack成功,自动添加数据
- (/hack/940)
- [2024-10-07 19:51:15]
- hack成功,自动添加数据
- (/hack/938)
- [2024-10-07 19:28:01]
- hack成功,自动添加数据
- (/hack/937)
- [2024-10-07 17:16:32]
- hack成功,自动添加数据
- (/hack/936)
- [2024-10-07 16:53:09]
- hack成功,自动添加数据
- (/hack/935)
- [2024-10-07 16:22:17]
- hack成功,自动添加数据
- (/hack/934)
- [2023-11-09 16:25:16]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(const char *s, auto ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int f = 0;
(..., (cerr << (f++ ? ", " : "") << a));
cerr << ")\e[0m\n";
}
void orange_(const char *s, auto L, auto R) {
cerr << "\e[1;33m[ " << s << " ] = [ ";
for (int f = 0; L != R; L++)
cerr << (f++ ? ", " : "") << *L;
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
void solve() {
int n, m;
cin >> n >> m;
vector<string> A(n), B(n);
for (int i = 0; i < n; i++) {
cin >> A[i];
}
for (int i = 0; i < n; i++) {
cin >> B[i];
}
{
vector<int> a(n), b(n);
iota(all(a), 0);
iota(all(b), 0);
sort(all(a), [&](int x, int y) { return A[x] < A[y]; });
sort(all(b), [&](int x, int y) { return B[x] < B[y]; });
string TA, TB;
for (int i : a) TA += A[i];
for (int i : b) TB += B[i];
if (TA == TB) {
for (int i = 0; i < n; i++)
cout << a[i] + 1 << (i+1==n ? '\n' : ' ');
for (int i = 0; i < n; i++)
cout << b[i] + 1 << (i+1==n ? '\n' : ' ');
return;
}
}
const auto ID = [](map<string, int> &mp, string s) -> int {
if (auto it = mp.find(s); it != mp.end())
return it->second;
return mp[s] = mp.size();
};
for (int k = 1; k < m; k++) {
map<string, int> lef, rig;
vector<vector<pair<int,int>>> g(n * 4);
for (int i = 0; i < n; i++) {
int L = ID(lef, A[i].substr(0, k));
int R = ID(rig, A[i].substr(k));
g[L * 2].emplace_back(R * 2 + 1, i);
}
for (int i = 0; i < n; i++) {
int R = ID(rig, B[i].substr(0, m - k));
int L = ID(lef, B[i].substr(m - k));
g[R * 2 + 1].emplace_back(L * 2, i + n);
}
vector<int> vis(n * 2), ans;
const auto dfs = [&](auto self, int i) -> void {
while (!g[i].empty()) {
auto [j, eid] = g[i].back(); g[i].pop_back();
vis[eid] = true;
self(self, j);
ans.push_back(eid);
}
};
dfs(dfs, 0);
if (ans.size() == n * 2) {
reverse(all(ans));
vector<int> L, R;
for (size_t i = 0; i < ans.size(); i += 2) {
L.push_back(ans[i]);
R.push_back(ans[i + 1]);
}
if (L[0] >= n) {
swap(L, R);
}
for (int i = 0; i < n; i++) {
cout << L[i] + 1 << (i+1==n ? '\n' : ' ');
}
for (int i = 0; i < n; i++) {
R[i] -= n;
cout << R[i] + 1 << (i+1==n ? '\n' : ' ');
}
return;
}
}
cout << -1 << '\n';
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t;
cin >> t;
while (t--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3416kb
input:
2 3 3 abc ghi def bcd efg hia 1 3 abc def
output:
1 3 2 1 2 3 -1
result:
ok 2 cases (2 test cases)
Test #2:
score: 0
Accepted
time: 308ms
memory: 3448kb
input:
1000000 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 b b 1 1 a b 1 1 b a 1 1 a a 1 1 ...
output:
1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 -1...
result:
ok 1000000 cases (1000000 test cases)
Test #3:
score: -100
Wrong Answer
time: 287ms
memory: 3448kb
input:
500000 1 2 dd ba 1 2 cd ba 1 2 bd ba 1 2 ad ba 1 2 dc ba 1 2 cc ba 1 2 bc ba 1 2 ac ba 1 2 db ba 1 2 cb ba 1 2 bb ba 1 2 ab ba 1 2 da ba 1 2 ca ba 1 2 ba ba 1 2 aa ba 1 2 dd aa 1 2 cd aa 1 2 bd aa 1 2 ad aa 1 2 dc aa 1 2 cc aa 1 2 bc aa 1 2 ac aa 1 2 db aa 1 2 cb aa 1 2 bb aa 1 2 ab aa 1 2 da aa 1 2...
output:
-1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
wrong answer not cyclic isomorphism (test case 9)