QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#858126 | #9922. Mah-jong | Itgsurf# | WA | 338ms | 3968kb | C++14 | 1021b | 2025-01-16 14:20:25 | 2025-01-16 14:20:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int mod=998244353;
const int N=1e5+5;
int T,n;
int s[8];
LL f[3][3][3][3][3][3][3][3];
int main(){
scanf("%d",&T);
while(T--){
memset(s,0,sizeof s);
memset(f,0,sizeof f);
f[0][0][0][0][0][0][0][0]=1;
scanf("%d",&n);
LL ans=0;
for(int i=0,a;i<n;++i){
scanf("%d",&a);
++s[--a];
for(int a0=0;a0<3&&a0<=s[0];++a0)
for(int a1=0;a1<3&&a0+a1<=s[1];++a1)
for(int a2=0;a2<3&&a0+a1+a2<=s[2];++a2)
for(int a3=0;a3<3&&a1+a2+a3<=s[3];++a3)
for(int a4=0;a4<3&&a2+a3+a4<=s[4];++a4)
for(int a5=0;a5<3&&a3+a4+a5<=s[5]&&a4+a5<=s[6]&&a5<=s[7];++a5)
ans+=f[(s[0]-a0)%3]
[(s[1]-a0-a1)%3]
[(s[2]-a0-a1-a2)%3]
[(s[3]-a1-a2-a3)%3]
[(s[4]-a2-a3-a4)%3]
[(s[5]-a3-a4-a5)%3]
[(s[6]-a4-a5)%3]
[(s[7]-a5)%3];
++f[s[0]%3][s[1]%3][s[2]%3][s[3]%3][s[4]%3][s[5]%3][s[6]%3][s[7]%3];
}
printf("%lld\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
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: 338ms
memory: 3968kb
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:
54611 65045 5863 2450 248073 7119 12431 48687 443481 1233932 19142 143983 306768 973691 223671 1693 91315 145847 73072 1 82628 0 42058 18421 90267 0 104563 167091 3 521177 61750 202416 28257 64928 31123 12820 2493 5247 78104 919402 178810 26044 870 91985 1320319 1840 13119 161273 12933 25118 27138 1...
result:
wrong answer 1st numbers differ - expected: '51699', found: '54611'