QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#198371#669. HashkjhhjkiWA 0ms3400kbC++201.6kb2023-10-03 13:25:392023-10-03 13:25:40

Judging History

This is the latest submission verdict.

  • [2023-10-03 13:25:40]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3400kb
  • [2023-10-03 13:25:39]
  • Submitted

answer

#include <bits/stdc++.h>
#define read() ({int x,c,f=1;while((c=getchar())<48||57<c)if(c=='-')f=-1;for(x=c^48;47<(c=getchar())&&c<58;)x=x*10+(c^48);x*f; })
using namespace std;
long long a, b;
string trans(long long hash)
{
    if (hash < a)
        return string(1, char(hash - 1 + 'a'));
    return trans(hash / a) + char(hash % a - 1 + 'a');
}
bool reg(const string &s)
{
    for (char c : s)
        if (!islower(c))
            return false;
    return true;
}
long long hash(const string &s)
{
    long long h = 0;
    for (char c : s)
        h = (h * a + c - 'a' + 1);
    return h;
}
int main()
{
    a = read(), b = read();
    if (a == 26)
    {
        string s;
        for (int i = 25; i--;)
            s += "ba";
        cout << s << '\n';
        for (int i = 0; i < 50; i += 2)
        {
            string t(s);
            t[i]--;
            t[i + 1] = 'z';
            cout << t << '\n';
        }
        int cnt = 26;
        for (int i = 0; i < 50; i += 2)
            for (int j = i + 2; j < 50; j += 2)
            {
                string t(s);
                t[i]--;
                t[i + 1] = 'z';
                t[j]--;
                t[j + 1] = 'z';
                cout << t << '\n';
                if (++cnt == 100)
                    return 0;
            }
    }
    string s;
    for (long long i = 0, cnt = 0; cnt < 100; ++i)
    {
        while (!reg(s = trans(1 + i * b)))
            i++;
        cnt++;
        cout << s << '\n';
        //printf("hash = %lld\n", ::hash(s));
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3400kb

input:

215465827 841597626

output:

a
ri
pi
ni
li
ji
hi
fi
di
vq
tq
rq
pq
nq
lq
jq
hq
fq
xy
vy
ty
ry
py
ny
ly
wf
jy
uf
hy
sf
qf
of
mf
kf
if
gf
yn
wn
un
sn
qn
on
mn
kn
in
yv
wv
uv
sv
qv
ov
zc
mv
xc
kv
vc
tc
rc
pc
nc
lc
jc
zk
xk
vk
tk
rk
pk
nk
lk
zs
xs
vs
ts
rs
ps
ns
az
yh
wh
uh
sh
qh
oh
yp
wp
up
sp
qp
dw
bw
ad
yx
wx
ux
sx
ze
xe
ve
te

result:

wrong answer different hash