func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 301;   int main() {     int n;     scanf( %d , &n);     vector<map<int, int> > rank(n);     for (int i = 0; i < (n); ++i) {       for (int j = 0; j < (n); ++j) {         int a;         scanf( %d , &a);         --a;         rank[i][a] = j;       }     }     vector<int> my(n);     for (int i = 0; i < (n); ++i) {       scanf( %d , &my[i]);       --my[i];     }     vector<int> ans(n), val(n);     fill(val.begin(), val.end(), n);     for (int i = 0; i < (n); ++i) {       int tar = -1;       for (int j = 0; j < (n); ++j)         if (my[j] <= i) {           tar = my[j];           break;         }       for (int j = 0; j < (n); ++j) {         if (j == tar) continue;         int r = rank[j][tar];         if (val[j] > r) {           val[j] = r;           ans[j] = i;         }       }       for (int j = 0; j < (n); ++j)         if (my[j] != tar && my[j] <= i) {           int k = my[j];           int r = rank[tar][k];           if (val[tar] > r) {             val[tar] = r;             ans[tar] = i;           }           break;         }     }     for (int i = 0; i < (n); ++i) {       printf( %d , ans[i] + 1);       if (i < n - 1)         putchar(   );       else         putchar(  n );     }     return 0;   }   