昨晚C题RE求调,悬关
  • 板块学术版
  • 楼主水星湖psgqwq
  • 当前回复12
  • 已保存回复12
  • 发布时间2024/8/14 20:03
  • 上次更新2024/8/14 22:35:44
查看原帖
昨晚C题RE求调,悬关
974277
水星湖psgqwq楼主2024/8/14 20:03

rt,fst了/kk

link

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 2e5 + 5;
int t, a[N];
vector<int> v1[N], v2[200];
map<int, int> mp;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> t;
    while(t--) {
        int n, cnt = 0; cin >> n;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
            if(!mp[a[i]]) mp[a[i]] = ++cnt;
            v1[mp[a[i]]].push_back(i);
        }
        int m; cin >> m;
        while(m--) {
            string s; cin >> s; 
            int len = s.size(), f = 0; 
            s = " " + s;
            if(len != n) {
                f = 1;
            }
            for(int i = 1; i <= len; i++) {
                v2[s[i]].push_back(i);
                // cout << s[i] << " " << i << endl;
            }
            
            for(int i = 1; i <= cnt; i++) {
                for(int j = 1; j < v1[i].size(); j++) {
                    if(s[v1[i][j]] != s[v1[i][j-1]]) {
                        f = 1;
                        // cout << s[v1[i][j]] << " " << s[v1[i][j-1]] << " 1"<< endl;
                        break;
                    }
                }
            }
            for(int i = 1; i < 200; i++)
                for(int j = 1; j < v2[i].size(); j++) {
                    if(a[v2[i][j]] != a[v2[i][j-1]]) {
                        f = 1;
                        // cout << v2[i][j] << " " << v2[i][j-1] << " 2"<<endl;
                        // cout << a[v2[i][j]] << " " << a[v2[i][j-1]] << " 2"<<endl;
                        break;
                    }
                }
            if(f == 1) puts("NO");
            else puts("YES");
            // puts
            for(int i = 1; i < 200; i++) v2[i].clear();
           
        }
        for(int i = 1; i <= cnt; i++) v1[i].clear();
         mp.clear();
    }
    

    return 0;
}

2024/8/14 20:03
加载中...