QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#322904 | #4828. Four Plus Four | bachbeo2007 | 0 | 598ms | 87576kb | C++23 | 3.5kb | 2024-02-07 22:27:35 | 2024-02-07 22:27:36 |
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_next(x);y<M;y=ny._Find_next(y)){
bitset<M> nz=ny&c[y];
for(int z=nz._Find_next(y);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';
assert(V[id][0]!=-1 && V[id][1]!=-1 && V[id][2]!=-1);
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];
assert(f[x][y]);
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: 571ms
memory: 84432kb
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: 569ms
memory: 84744kb
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 keir kier
input:
keys 1 keir kier 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: 579ms
memory: 83800kb
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 kava dark fold frow farl arak kava dark
input:
keys 18 kava dark arak dark farl fold arak kava arak dark dark kava frow farl fold frow dark arak farl frow kava dark fold farl arak kava dark kava kava arak frow fold dark arak kava 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: 570ms
memory: 87160kb
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 kava dark fold frow farl egal also goes cuss baas aces aeon baas lobs bear maar peer anna nods sand laic lipa baal 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 bait acta 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 tubs nisi desk bear bird sike riot agio emir nose doom also sola lief fila rest kibe tune duet loco load unco curn dita dish plat fays cite itch sall cels tern ides ores gels cain corf alif fair seed 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: 100
Accepted
time: 598ms
memory: 87576kb
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 lung here fuse serf seel full sure glen full flue floe owed flue tufa cuif gift fuse gift figs gift etui give egal fame gaum glen mule lung fuss gift gits curl slum urus lull ills fils club full bulk fere full rule alec face full lens slue fuss meld lief muni mels fuse flue ...
input:
keys 60000 tens rias riot heth rill iron rend oped sept sloe poet poke post oped lobe rile drew rood prat lota raki vice riot nuts purl yelp roti rove pops nays anna nota gown owns rias seel nail quay dens seel grey eyer oats cone duet curt purr sept wilt moil aeon mane tyre alec user mere must mane...
output:
inertias hitherto hornbill proponed pollster pokeroot imposted overbill overword platform maverick outrings plumbery inventor pansophy nanowatt knowings realiser quaintly linseeds greenery notecase pictured posturer milkwort moonbeam rectally presumer nutmeats legality hidrosis panderer haunches ove...
result:
ok OK
Test #6:
score: 0
Stage 1: Program answer Runtime Error
input:
password 8488 redounds redpolls redrafts redrawer redreams redreamt redrills redriven redrives redroots redrying redshank redshift redshirt redskins redstart redtails redubbed reducers reducing reductor reduviid redwares redwings redwoods redyeing reearned reechier reechoed reechoes reedbird reedbuc...
output:
ores unde duds oped olds oles rest fard read rede awee rare mead sear rams mead rate mart rile side ides rend rive vied reis dive vees ores dots tods rend gyre yirr hank sard sear reis deft feds rest shed dits reis skis kirn rest sard date rile tads sear rudd bred bedu dues crud curs rend guid iced ...