2020 华为笔试题——Trie树

#include 
using namespace std;
int main() {
   int M;
   cin >> M;
   vector> nums(3, vector(M));
   for (int i = 0; i < 3; i++) {
      for (int j = 0; j < M; j++) {
         cin >> nums[i][j];
      }
   }
   int N;
   cin >> N;
   vector values(N);
   for (int i = 0; i < N; i++) {
      cin >> values[i];
   }
   int K;
   cin >> K;
   vector keys(K);
   int count = 0;
   for (int i = 0; i < K; i++) {
      cin >> keys[i];
      for (int j = 0; j < M; j++) {
         if (keys[i] == nums[0][j] && nums[1][j] == 1 && j <= N) {
            cout << values[j];
            count++;
            break;
         }
      }
   }
   if (count == 0) {
      cout << 0;
   }
   return 0;
}

note:未AC

你可能感兴趣的:(秋招笔试题)