제출 #1124365

#제출 시각아이디문제언어결과실행 시간메모리
1124365math_rabbit_1028상형문자열 (IOI24_hieroglyphs)C++20
3 / 100
31 ms5504 KiB
#include "hieroglyphs.h" using namespace std; vector<int> solve(vector<int> A, vector<int> B) { int N = (int)A.size(); int M = (int)B.size(); vector<int> cntA(202020, 0), cntB(202020, 0), ret; int p = 0; for (int i = 0; i < N; i++) { cntA[A[i]]++; } for (int i = 0; i < M; i++) { cntB[B[i]]++; } for (int i = 0; i < N; i++) { if (cntB[A[i]] == 0) continue; while (true) { if (B[p] == A[i]) { p++; ret.push_back(A[i]); cntA[A[i]]--; cntB[A[i]]--; break; } p++; if (p == M) return vector<int>(1, -1); } } return ret; } vector<int> check(vector<int> V, vector<int> U) { if (V.size() > U.size()) swap(V, U); // V.size() <= U.size() int p = 0; for (int i = 0; i < V.size(); i++) { while (true) { if (p == U.size()) return vector<int>(1, -1); if (V[i] == U[p]) { p++; break; } p++; } } return U; } vector<int> ucs(vector<int> A, vector<int> B) { vector<int> V = solve(A, B); vector<int> U = solve(B, A); if (V.size() == 1 && V[0] == -1) return vector<int>(1, -1); if (U.size() == 1 && U[0] == -1) return vector<int>(1, -1); return check(V, U); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...