QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#561002#8690. Archaeological RecoveryPhantomThreshold#WA 0ms3872kbC++202.3kb2024-09-12 19:26:172024-09-12 19:26:18

Judging History

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

  • [2024-09-12 19:26:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-09-12 19:26:17]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define int long long
#define lowbit(x) ((x)&(-x))
using namespace std;

const int maxn = 500;

int n,K,T,S;
int ci[300]; char cc[5];

int trans(int x,int c)
{
    vector<int>v(10);
    for(int i=0;i<K;i++)
    {
        v[i]= x%3;
        x/=3;
        v[i]=(v[i]+c%3)%3;
        c/=3;
    }
    for(int i=K-1;i>=0;i--) x=x*3+v[i];
    return x;
}
int num[300];
int ans[maxn],vis[maxn],go[maxn];
int check(int c)
{
    if(c==0)
    {
        for(int i=0;i<S;i++) if(num[i]%2==1)
            return 0;
        for(int i=0;i<S;i++) num[i]>>=1;
        return 1;
    }
    else
    {
        for(int i=0;i<S;i++) vis[i]=0,go[i]=0;
        for(int i=0;i<S;i++) if(vis[i]==0)
        {
            int x=i, y=trans(x,c), z=trans(y,c);
            vis[x]=vis[y]=vis[z]=1;

            if( (num[x]+num[y]+num[z])%2==1 ) return 0;
            go[x]= (num[x]+num[y]-num[z])/2;
            go[y]= (num[y]+num[z]-num[x])/2;
            go[z]= (num[z]+num[x]-num[y])/2;

            if(go[x]<0 or go[y]<0 or go[z]<0) return 0;

            if(i==0)
            {
                if( go[0]==0 ) return 0;
            }
        }
        for(int i=0;i<S;i++)
        {
            num[i]=go[i];
        }
        return 1;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);

    ci['A']=0,ci['E']=1,ci['I']=2;
    cc[0]='0',cc[1]='+',cc[2]='-';

    cin>>n>>K>>T;
    S=1;
    for(int i=1;i<=K;i++) S*=3;
    for(int i=1;i<=T;i++)
    {
        string ss; cin>>ss;
        int now=0;
        for(int j=0;j<K;j++) 
        {
            int w= ci[(int)ss[j]];
            now=now*3+w;
        }
        cin>>num[now];
    }
    mt19937 rng(58);
    for(int i=1;i<=n;i++)
    {
        vector<int>perm(S);
        for(int c=0;c<S;c++) perm[c]=c;
        random_shuffle(perm.begin(),perm.end(),[&](int x){return rng()%x;});
        for(int c=0;c<S;c++) if(check(perm[c]))
        {
            ans[i]=perm[c];
            break;
        }
    }

    for(int i=1;i<=n;i++)
    {
        int x=ans[i];
        string ai;
        for(int j=0;j<K;j++) ai.push_back(cc[x%3]),x/=3;
        reverse(ai.begin(),ai.end());
        cout<<ai<<endl;
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 3 14
IEA 1
AEI 1
AIE 1
EAE 2
IAA 1
AAI 1
AAA 2
AEE 1
IAE 1
EII 1
EEA 1
EAI 1
IIE 1
EIA 1

output:

+0+
0-+
+0-
-+0

result:

ok correct plan!

Test #2:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

1 1 2
I 1
A 1

output:

-

result:

ok correct plan!

Test #3:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

1 5 2
AEAAA 1
AAAAA 1

output:

0+000

result:

ok correct plan!

Test #4:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

1 4 1
AAAA 2

output:

0000

result:

ok correct plan!

Test #5:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

2 1 1
A 4

output:

0
0

result:

ok correct plan!

Test #6:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

4 4 12
AAIA 1
AAAA 2
IEIE 1
IAAA 1
AEEE 2
IAEA 1
IAIA 2
IEAE 2
IEEE 1
AAEA 1
AEIE 1
AEAE 1

output:

-0-0
00-0
00+0
0+++

result:

ok correct plan!

Test #7:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

7 5 107
IAAIA 1
EIIEE 1
EEEIA 1
IEIAI 1
AEAAI 2
AAEIE 1
IIEEI 1
IIAII 1
IEEEA 1
IAAEI 1
EAIEA 1
IIAAA 2
AEEEE 1
IIEEA 1
IEEIA 1
AAEAI 1
EAIEE 2
EEEIE 3
IAIEA 1
AAIIA 1
EAIII 1
EAIIE 1
IIEIE 2
AAAIE 2
AAAAA 1
IEAIE 1
AEAEI 1
AEIII 1
IAEEA 1
IIIIE 1
AAIEA 1
EIIIE 1
EIAAE 1
AEEIA 1
EEAII 1
IAEIA 1
IIAE...

output:

---0+
-+0-+
0+0+-
+0--+
--+-+
-0-++
00--0

result:

ok correct plan!

Test #8:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

4 4 15
EIIA 1
IEIE 1
AAAA 1
IIIE 1
AEAA 1
IIAI 1
EAEI 1
EAAE 1
IAIE 2
AAEE 1
AEII 1
EIEI 1
IEEA 1
IAAI 1
IAEA 1

output:

00++
---+
-0-+
0+--

result:

ok correct plan!

Test #9:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

6 5 62
EAAEA 1
AAIII 1
EEEII 1
IIAIE 1
EAIEA 1
IEEII 1
IEAIA 1
IEIEE 1
IAIEE 1
AAEEI 1
EEAEE 1
EIIEA 1
AEEEI 1
AIAIA 1
EAEIE 1
IIIIE 1
IIIEA 1
EAAII 1
IIAAA 1
AAIIA 1
IIEIA 1
EIEII 1
IEAEA 1
EEAAE 1
EEAEA 1
AEAAE 1
IEAAE 1
EEAAI 1
EEEEA 1
AIEEA 1
IEEAE 1
AIAAI 1
EAEEE 1
IAAII 1
IAEIA 1
AAAAE 2
IAAEA...

output:

+00+-
+-0+-
----+
++00+
-++00
++0+0

result:

ok correct plan!

Test #10:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

6 5 62
IEAEI 1
IAEAE 1
IEIAA 1
IAIEE 1
IIIIA 1
EEIIA 1
EAEIE 1
EEEIE 1
AEAEI 1
IIEAA 1
AIEII 1
EAIII 1
AIIIA 1
AAAAA 1
IAEEI 1
EEIAE 1
AAAII 1
IAAEI 1
IAAAE 1
AIIAE 1
IEEEE 1
EEIAA 1
IAAIA 1
EAIAI 1
IIAIE 1
EEAAI 1
EEIEI 1
IEIIA 1
EAAEE 1
IIIEA 1
IEAEA 1
AIEAE 2
AEEAA 1
EEAIE 1
EAAEI 1
EIAEA 1
IAIEA...

output:

-0++-
+-+--
0---0
-++--
-+0+-
00--+

result:

ok correct plan!

Test #11:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

5 4 31
EAIA 1
AAIE 1
EAAE 1
AEEA 1
AAEA 1
IIAA 1
AIAE 1
EEEE 1
EAAA 1
IIEI 1
AAAA 1
EEAI 1
AAII 2
EEII 1
IIAE 1
AAIA 1
AAEE 1
AEAI 1
EIAA 1
IAII 1
EEEA 1
IIII 1
IAEA 1
AAAE 1
EIII 1
IEEE 1
AIEI 1
IAIE 1
IAEE 1
EAII 1
IEII 1

output:

++--
+000
--+-
00--
-0-+

result:

ok correct plan!

Test #12:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

7 5 90
EIAIA 1
AIEIA 1
IIAAA 1
EEAAE 1
EEAAA 1
AEEIA 3
EEIAA 2
IEEIE 1
IAAIE 1
AEIAE 2
EIAAE 3
AIIAI 1
EEAIE 1
EEIII 2
EEEII 1
IIIII 1
IAEIE 2
AIAAI 1
IEEII 1
EAEAI 3
AIIII 1
AEIIA 1
AAIII 1
EAAIA 1
AAEIA 1
EEEAI 1
EIIII 1
IIAAI 2
EIIIA 1
EAEAE 2
EEEIE 2
AEAII 2
EIAAA 1
AEEIE 2
AAIIE 1
EAEAA 1
IAEAE...

output:

+--0+
--+--
0--0-
+--00
0+-0+
00+0+
0++0+

result:

ok correct plan!

Test #13:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

4 5 16
IEAEE 1
EEAEE 1
EAIAE 1
IEAAI 1
IAAAA 1
IEEAE 1
IAIEA 1
AAIEA 1
EEEEA 1
AAIAE 1
AEEEA 1
EAAEI 1
AEAAI 1
EEEAE 1
IAAEI 1
AAAAA 1

output:

-++0+
+0-0+
-0000
-00+-

result:

ok correct plan!

Test #14:

score: -100
Wrong Answer
time: 0ms
memory: 3676kb

input:

9 4 81
AAAI 4
IIAI 6
AIAA 3
AEEE 5
IEAE 8
AEEI 8
IEAA 5
IAEI 8
AIAI 5
IIIE 7
EIII 7
AEIA 5
IEEI 5
EAEE 5
EAAE 8
AAII 7
EAIA 5
IEAI 9
IAAA 4
EEII 5
IAII 7
EEIA 6
EIEA 3
AEEA 7
EEAI 6
EIEE 5
EEAE 11
EEAA 7
EEEE 4
AEAI 5
AAEI 11
IIEE 6
AIIE 7
AIEI 7
IEII 4
IEEA 4
AAAA 5
AAEE 6
AEIE 6
IAEE 9
IIAE 7
IAIA...

output:

----
++++
0000
0000
0000
0000
0000
0000
0000

result:

wrong answer wrong answer, for the configuration AAAA expected 5, but you obtained 256