第四题 int n1, n2, q; int main() { cin >> n1 >> n2 >> q; vector<int> q1; vector<int> q2; vector<bool> vis(n1+n2+1,false); for (int i = 1; i <= n1; i++) { q1.push_back(i); vis[i] = false; } for (int i = n1+1; i <= n1+n2; i++) { q2.push_back(i); vis[i] = true; } int a; for (int i = 0; i < q; i++) { cin >> a ; if (!vis[a]) { q2.push_back(a); vis[a] = true; } else { q1.push_back(a); vis[a] = false; } } vector<bool> vis1(n1 + n2 + 1, false); vector<int> c1; for (int k = q1.size()-1; k>=0; k--) { if (!vis[q1[k]] && !vis1[q1[k]]) { vis1[q1[k]] = true; c1.push_back(q1[k]); } } vector<bool> vis2(n1 + n2 + 1, false); vector<int> c2; for (int k = q2.size() - 1; k >= 0; k--) { if (vis[q2[k]] && !vis2[q2[k]]) { vis2[q2[k]] = true; c2.push_back(q2[k]); } } for (int k = c1.size() - 1; k >= 0; k--) { cout << c1[k] << " "; } cout << endl; for (int k = c2.size() - 1; k >= 0; k--) { cout << c2[k] << " "; } return 0; }