QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#730140#5311. Master of BothFluoresceWA 52ms24668kbC++201.6kb2024-11-09 18:51:152024-11-09 18:51:16

Judging History

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

  • [2024-11-09 18:51:16]
  • 评测
  • 测评结果:WA
  • 用时:52ms
  • 内存:24668kb
  • [2024-11-09 18:51:15]
  • 提交

answer

#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define debug(a) cout<<a<<'\n'
#define Pll pair<ll,ll>
#define PII pair<int,int>
#define ft first
#define sd second
#define vec vector
#define pushk push_back
#define ump unordered_map
#define pl p<<1
#define pr p<<1|1
using namespace std;
const int N = 5e5 + 10, M = 1e6 + 10, mod = 1e9+7;
const ll inf = 1e18;
const ld eps = 1e-13;
int mov[4][2] = { {0,1},{1,0},{-1,0},{0,-1} }, dx, dy, _ = 1, __ = 1;
void bout(bool f) {
	if (f)cout << "YES\n";
	else cout << "NO\n";
}
ll n,m,k;
int tr[M][26],num[M],idx;
ll re[30][30];
int pos[30]; 

void insert(string &s){
	int p=0,c;
	for(int i=0;i<s.length();++i){
		c=s[i]-'a';
		for(int j=0;j<26;++j){
			if(j==c)continue;
			else re[c][j]+=num[tr[p][j]];
		}
		if(!tr[p][c])tr[p][c]=++idx;
		p=tr[p][c];
		++num[p];
	}
}


void ini() {

}
void solve() {
	cin>>n>>k;
	string s;
	for(int i=1;i<=n;++i){
		cin>>s;
		insert(s);
	}
	int c,x,y;
	while(k--){
		cin>>s;
		for(int i=0;i<26;++i){
			c=s[i]-'a';
			pos[c]=i;	
		}
		ll ans=0;
		for(int i=0;i<26;++i){
			for(int j=0;j<26;++j){
				if(pos[i]<pos[j])ans+=re[i][j];
			}
		}
		cout<<ans<<'\n';
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	streambuf *cinbp=cin.rdbuf(),*coutbp=cout.rdbuf();
	ifstream fin("in.txt");
	ofstream fout("out.txt");	
	cin.rdbuf(fin.rdbuf());
	cout.rdbuf(fout.rdbuf());
#endif
	//cin >> _;
	__ = _;
	ini();
	while (_--) {
		solve();
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

input:

5 3
aac
oiputata
aaa
suikabudada
aba
abcdefghijklmnopqrstuvwxyz
qwertyuiopasdfghjklzxcvbnm
aquickbrownfxjmpsvethlzydg

output:

4
3
4

result:

ok 3 number(s): "4 3 4"

Test #2:

score: 0
Accepted
time: 12ms
memory: 24668kb

input:

100 100
spkfvrbkfsspmnlgrdojwdqutknvzejorqxsmfgbfrhpxkrrtravhmxenjrzypkxounrbantpkaezlcnudjmwxpgqakfoxcmdjcygujdtpluovbisxmklkzzuuyziapzyrszcggjkzrwmtyolnbobubbezdwmumyzyhaogiiolictzjpxbyaamecytpnyzxlumxjkzyfavxlzdwtgrxtqcnddzfocznitlaxlpcceuelqlbmyzetlpaivxnuvuctsbjbaulmbmkangqahpdojqimvmcugjeczkgx...

output:

2368
2693
2179
2466
2435
2370
2604
2468
2335
2268
2686
2781
2538
2208
2386
2539
2728
2383
2248
2372
2446
2266
2290
2688
2602
2515
2634
2558
2598
2632
2763
2255
2557
2579
2367
2516
2676
2273
2429
2556
2576
2635
2422
2829
2362
2552
2377
2261
2603
2516
2298
2282
2520
2333
2505
2287
2261
2476
2791
2328
...

result:

ok 100 numbers

Test #3:

score: -100
Wrong Answer
time: 52ms
memory: 18248kb

input:

500000 5
ru
x
tb
s
e
w
e
m
l
b
g
zr
jp
h
js
xk
fjwtk
wtkem
o
ev
a
a
x
sy
dh
y
kkdcxfr
hgq
j
k
xr
s
cvwbrlk
u
u
x
wtvgef
dzxsk
qv
gxl
g
m
rpl
ldp
q
lc
dk
g
k
im
o
yhn
z
a
knc
tyv
mz
ak
qdhq
c
niw
o
j
heu
w
g
e
kt
n
inqt
i
al
q
ebphky
sv
m
mry
oj
cl
j
r
sf
vpd
u
rio
sfkg
m
el
s
zs
g
o
e
njp
r
xczcm
gh...

output:

60698136185
60730188741
60672616223
60740783841
60714178255

result:

wrong answer 1st numbers differ - expected: '61908555824', found: '60698136185'