QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#322898 | #4828. Four Plus Four | bachbeo2007 | 0 | 605ms | 87912kb | C++23 | 3.4kb | 2024-02-07 22:19:40 | 2024-02-07 22:19:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define mpp make_pair
#define fi first
#define se second
const int N=28558,M=3919;
int S[]={2,3,2,2,3,2,2,2,2,2,2,3,3,2,2,2,1,3,3,2,2,2,2,1,2,2};
struct Password{
string s;
ull mask=0;
Password(){};
Password(string ss):s(ss){
vector<int> cnt(26);
for(char c:s) cnt[c-'a']++;
int total=0;
for(int i=0;i<26;i++){
mask+=((1ULL<<min(S[i],cnt[i]))-1)<<total;
total+=S[i];
}
}
int submask(Password P){
return (mask&P.mask)==P.mask;
}
friend bool operator<(Password a,Password b){
return a.s<b.s;
}
};
int f[M][M];
Password P[N],K[M];
vector<int> V[N];
map<string,int> key,pass;
bitset<M> g[N],c[M];
void init(){
int n;cin >> n;
for(int i=0;i<N;i++){
string s;cin >> s;
P[i]=s;pass[s]=i;
}
int m;cin >> m;
for(int i=0;i<M;i++){
string s;cin >> s;
K[i]=s;
}
shuffle(K,K+M,mt19937_64(9112001));
for(int i=0;i<M;i++) key[K[i].s]=i;
vector<pii> order(N);
for(int i=0;i<N;i++){
order[i].se=i;
for(int j=0;j<M;j++){
g[i][j]=P[i].submask(K[j]);
}
order[i].fi=g[i].count();
}
sort(order.begin(),order.end());
for(int i=0;i<M;i++) c[i].set();
for(auto [cnt,id]:order){
if(cnt<3) continue;
//cout << cnt << ' ' << id << endl;
vector<int> res;
function<vector<int>()> get = [&](){
for(int x=g[id]._Find_first();x<M;x=g[id]._Find_next(x)){
bitset<M> ny=g[id]&c[x];
for(int y=ny._Find_first();y<M;y=ny._Find_next(y)){
bitset<M> nz=ny&c[y];
for(int z=nz._Find_first();z<M;z=nz._Find_next(z)) return res={x,y,z};
}
}
for(int x=g[id]._Find_first();x<M;x=g[id]._Find_next(x)){
if(c[x][x]) return res={x,x,x};
}
return res={-1,-1,-1};
};
V[id]=get();
int x=V[id][0],y=V[id][1],z=V[id][2];
if(x==-1) continue;
c[x][y]=c[x][z]=c[y][z]=c[y][x]=c[z][x]=c[z][y]=0;
f[x][y]=f[x][z]=f[y][z]=f[y][x]=f[z][x]=f[z][y]=id+1;
}
}
void encode(string s){
int id=pass[s];
//cout << id << ' ' << V[id][0] << ' ' << V[id][1] << ' ' << V[id][2] << '\n';
cout << K[V[id][0]].s << ' ' << K[V[id][1]].s << ' ' << K[V[id][2]].s << '\n';
}
void decode(string a,string b){
int x=key[a],y=key[b];
cout << P[f[x][y]-1].s << '\n';
}
void solve(){
string type;cin >> type;
int n;cin >> n;
vector<pair<string,string>> p(n);
if(type=="password"){
for(int i=0;i<n;i++) cin >> p[i].fi;
}
else{
for(int i=0;i<n;i++) cin >> p[i].fi >> p[i].se;
}
init();
if(type=="password"){
for(int i=0;i<n;i++) encode(p[i].fi);
}
else{
for(int i=0;i<n;i++) decode(p[i].fi,p[i].se);
}
}
signed main(){
//freopen("input.txt","r",stdin);
//freopen("001.phase1.full.input","r",stdin);
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
int test=1;//cin >> test;
while(test--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 605ms
memory: 83592kb
input:
password 2 password couthier 28558 aardvark aardwolf aasvogel abacuses abalones abampere abandons abapical abasedly abashing abatable abatises abattoir abbacies abbatial abbesses abdicate abdomens abdomina abducens abducent abducing abducted abductee abductor abelmosk aberrant abetment abettals abet...
output:
sard wrap wops riot ouch true
input:
keys 4 sard wrap true ouch wops sard wrap wops 28558 aardvark aardwolf aasvogel abacuses abalones abampere abandons abapical abasedly abashing abatable abatises abattoir abbacies abbatial abbesses abdicate abdomens abdomina abducens abducent abducing abducted abductee abductor abelmosk aberrant abet...
output:
password couthier password password
result:
ok OK
Test #2:
score: 100
Accepted
time: 572ms
memory: 84240kb
input:
password 1 quirkier 28558 aardvark aardwolf aasvogel abacuses abalones abampere abandons abapical abasedly abashing abatable abatises abattoir abbacies abbatial abbesses abdicate abdomens abdomina abducens abducent abducing abducted abductee abductor abelmosk aberrant abetment abettals abetters abet...
output:
ruer ruer ruer
input:
keys 1 ruer ruer 28558 aardvark aardwolf aasvogel abacuses abalones abampere abandons abapical abasedly abashing abatable abatises abattoir abbacies abbatial abbesses abdicate abdomens abdomina abducens abducent abducing abducted abductee abductor abelmosk aberrant abetment abettals abetters abettin...
output:
quirkier
result:
ok OK
Test #3:
score: 100
Accepted
time: 572ms
memory: 84176kb
input:
password 3 aardvark aardwolf aardvark 28558 aardvark aardwolf aasvogel abacuses abalones abampere abandons abapical abasedly abashing abatable abatises abattoir abbacies abbatial abbesses abdicate abdomens abdomina abducens abducent abducing abducted abductee abductor abelmosk aberrant abetment abet...
output:
arak arak arak fold frow farl arak arak arak
input:
keys 18 arak arak arak arak farl fold arak arak arak arak arak arak frow farl fold frow arak arak farl frow arak arak fold farl arak arak arak arak arak arak frow fold arak arak arak arak 28558 aardvark aardwolf aasvogel abacuses abalones abampere abandons abapical abasedly abashing abatable abatise...
output:
aardvark aardvark aardwolf aardvark aardvark aardvark aardwolf aardwolf aardvark aardwolf aardvark aardwolf aardvark aardvark aardvark aardwolf aardvark aardvark
result:
ok OK
Test #4:
score: 100
Accepted
time: 587ms
memory: 87912kb
input:
password 10000 aardvark aardwolf aasvogel abacuses abalones abampere abandons abapical abasedly abashing abatable abatises abattoir abbacies abbatial abbesses abdicate abdomens abdomina abducens abducent abducing abducted abductee abductor abelmosk aberrant abetment abettals abetters abetting abetto...
output:
arak arak arak fold frow farl egal also goes cuss baas beau aeon baas lobs bear maar peer anna nods sand laic lipa lipa blae dyes sled shag baas bigs blae belt late bise eats bait riot bott boar bise case cabs lati bail bait abbe ease bass aide debt bait aeon beds dams bind mina modi dues cane cabs ...
input:
keys 60000 egal cain heel feel clit efts zags aeon nodi cedi foin grig rest turk nisi desk bear bird sike riot agio emir nose mood also also lief fila rest kibe tune tuna loco lean unco curn dita tide plat fays beth itch sall cels tern ides ores sego cain corf alif fair ides reis woof form anta vain...
output:
cleaning fleeches felsitic agonizes coincide frogging bruskest dinkiest arabized forkiest armigero endosome falloffs fallible briskest denudate canoodle conquers dashiest flypasts bioethic carrells dextrins cloggers fricando filarees dressier formwork aviating dogeship arousals celestas buttocks epi...
result:
ok OK
Test #5:
score: 0
Wrong Answer on the first run
input:
password 10000 fucoidal fuddling fuehrers fuellers fuelling fuelwood fugacity fuggiest fugitive fugleman fuglemen fuguists fulcrums fulfills fullback fullered fullface fullness fulmined fulmines fulminic fumarase fumarate fumarole fumatory fumblers fumbling fumeless fumelike fumettes fumigant fumiga...
output:
fold cuif coda gild guid guid here fuse serf seel full surf glen full flue floe owed flue tufa cuif gift fuse gift figs gift gift gift egal fame gaum glen mule fume fuss gift gits curl slum urus lull ills sill club full bulk fere full dell alec face full lens slue fuss meld lief mine mels fuse flue ...
input:
output:
result:
wrong answer dues didn't appear in guzzling