QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#275644#5311. Master of Bothchitoge#WA 8ms81748kbC++231.2kb2023-12-04 22:00:562023-12-04 22:00:57

Judging History

你现在查看的是最新测评结果

  • [2023-12-04 22:00:57]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:81748kb
  • [2023-12-04 22:00:56]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")


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

vector<pair<int,int>> pex[1000001];

#define endl '\n'

int rex[27][27];

// set<pair<int,int> > vis;
unordered_set<int> vis[1000001];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,q;cin>>n>>q;
    string s;
    int maxlen=0;
    for(int i=0;i<n;i++){
        cin>>s;
        for(int j=0;j<s.size();j++){
            pex[j].push_back(make_pair(s[j]-'a',i));
        }
        maxlen=max(maxlen,(int)s.size());
    }

    for(int i=0;i<maxlen;i++){
        for(int j=1;j<pex[i].size();j++){
            for(int k=0;k<j;k++){
                if(vis[pex[i][j].second].count(pex[i][k].second))continue;
                    rex[pex[i][j].first][pex[i][k].first]++;
                    vis[pex[i][j].second].insert(pex[i][k].second);
                
            }
        }
    }

    for(int i=0;i<q;i++){
        string s;
        cin>>s;
        long long ans=0;
        for(int l=0;l<26;l++){
            for(int r=l+1;r<26;r++){
                ans+=rex[s[l]-'a'][s[r]-'a'];
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 8ms
memory: 81748kb

input:

5 3
aac
oiputata
aaa
suikabudada
aba
abcdefghijklmnopqrstuvwxyz
qwertyuiopasdfghjklzxcvbnm
aquickbrownfxjmpsvethlzydg

output:

3
2
3

result:

wrong answer 1st numbers differ - expected: '4', found: '3'