QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#831643#9922. Mah-jongucup-team4479#WA 693ms3724kbC++231.2kb2024-12-25 15:51:052024-12-25 15:51:05

Judging History

This is the latest submission verdict.

  • [2024-12-25 15:51:05]
  • Judged
  • Verdict: WA
  • Time: 693ms
  • Memory: 3724kb
  • [2024-12-25 15:51:05]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int N=100005,C=8;
int n;
int a[N];
int sum[6561];
int cur[C+1];
int cnt[C+1];
long long ans;
void dfs(int step,int val)
{
    if(step>C-2)
    {
        val=val*3+cur[step]%3,step++;
        val=val*3+cur[step]%3,step++;
        ans+=sum[val];
        return;
    }
    for(int c=0;c<=2;c++)
    {
        cnt[step]+=c;
        cnt[step+1]+=c;
        cnt[step+2]+=c;
        if(cnt[step]<=cur[step]&&cnt[step+1]<=cur[step+1]&&cnt[step+2]<=cur[step+2]) dfs(step+1,val*3+(cur[step]-cnt[step])%3);
        cnt[step]-=c;
        cnt[step+1]-=c;
        cnt[step+2]-=c;
    }

    return;
}
void solve()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    memset(cur,0,sizeof(cur));
    memset(sum,0,sizeof(sum));
    sum[0]=1;
    ans=0;
    for(int i=1;i<=n;i++)
    {
        cur[a[i]]++;
        dfs(1,0);
        int val=0;
        for(int j=1;j<=C;j++)
            val=val*3+cur[j]%3;
        sum[val]++;
    }
    cout<<ans<<"\n";
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int T;
    cin>>T;
    while(T--)
        solve();
    return 0;
}

詳細信息

Test #1:

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

input:

5
4
1 1 1 1
6
1 2 3 1 2 3
7
6 5 8 7 6 3 2
8
1 2 1 2 1 2 1 3
9
2 2 4 4 1 1 1 3 3

output:

2
5
1
3
2

result:

ok 5 number(s): "2 5 1 3 2"

Test #2:

score: -100
Wrong Answer
time: 693ms
memory: 3724kb

input:

100
992
8 1 8 1 2 3 6 6 1 3 1 8 7 7 4 7 7 1 6 6 4 8 3 7 3 5 1 4 4 7 5 7 5 7 4 3 7 5 2 8 7 1 6 3 6 2 4 3 2 3 1 6 3 1 3 2 6 6 7 4 6 1 1 4 6 4 7 7 8 5 6 4 1 5 4 8 2 4 4 2 1 3 5 7 6 8 3 7 6 6 5 6 4 2 5 4 3 7 3 5 5 3 3 2 7 8 2 7 2 4 4 3 4 1 1 3 5 5 4 6 3 3 3 2 6 1 2 6 4 8 8 6 6 8 7 3 1 1 8 8 7 2 5 6 3 5 ...

output:

55438
65545
6238
2880
251840
8163
13282
49079
448285
1239942
19963
149425
317031
982569
229395
1719
93271
147594
74246
1
88467
0
44951
20175
93327
0
105644
175240
3
524804
62839
204819
29829
65753
32833
12894
2581
5643
79482
931319
185753
27499
1052
92537
1327075
2124
14152
163578
13711
25974
28268
...

result:

wrong answer 1st numbers differ - expected: '51699', found: '55438'