QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#847470 | #9922. Mah-jong | fang_baby | WA | 2416ms | 3620kb | C++23 | 5.0kb | 2025-01-08 00:02:35 | 2025-01-08 00:02:36 |
Judging History
answer
/*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define maxn 200005
mt19937_64 rng {std::chrono::steady_clock::now().time_since_epoch().count()};
ll mod = 998244353;
ll MOD = 998244353;
//cout<<"panduan\n";
//auto dfs = [&](auto &self,int x,int f)->void{self(self,x,f);};
void solve(){
int n = 0;
cin>>n;
vector<int>arr(n);
vector<int>temp(729);
for(int i = 0;i<n;i++){
cin>>arr[i];
arr[i]--;
}
int all[7] = {0};
//all[0] = 1;
ll ans = 0;
for(int i = 0;i<729;i++){
//int i = 1;
int num[8] = {0};
vector<int>cnt(6561);
for(int j = 0;j<6;j++){
if(all[j]){
num[j]-=all[j];
num[j+1]-=all[j];
num[j+2]-=all[j];
}
}
//for(int j = 0;j<8;j++)cout<<num[j]<<"\n";
int num2[8] = {0};
int num3[8] = {0};
int num4[8] = {0};
for(int j = 0;j<8;j++){
if(num[j]<-3){
num4[j] = -3;
}else{
num4[j] = num[j]%3;
}
}
int ok2 = 1;
int ok = 0;
for(int k = 0;k<8;k++){
if(num[k]<num4[k]){
ok2 = 0;
break;
}
}
if(ok2)
cnt[0]++;
for(int j = 0;j<n;j++){
num2[arr[j]]++;
num[arr[j]]++;
if(num2[arr[j]]==3){
num2[arr[j]] = 0;
}
ok = 1;
ok2 = 1;
for(int k = 0;k<8;k++){
if(num[k]<num4[k]){
ok2 = 0;
break;
}
}
for(int k = 0;k<8;k++){
num3[k] = num2[k];
if(num[k]<0){
ok = 0;
break;
}
}
int haha = 0,te = 1;
int haha2 = 0;
for(int k = 0;k<6;k++){
num3[k] = (num3[k]-all[k]+3)%3;
num3[k+1] = (num3[k+1]-all[k]+3)%3;
num3[k+2] = (num3[k+2]-all[k]+3)%3;
}
for(int k = 0;k<8;k++){
haha+=num2[k]*te;
haha2+=num3[k]*te;
te*=3;
}
if(ok)ans+=cnt[haha2];
if(ok2)cnt[haha]++;
}
all[0]++;
int dex = 0;
while(dex<=5&&all[dex]>=3){
all[dex++] = 0;
all[dex]++;
}
}
cout<<ans<<"\n";
}
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t = 1;
cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3620kb
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: 2416ms
memory: 3584kb
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:
51537 62230 4797 2006 243769 6249 10855 45416 432882 1214669 17710 139402 299953 958648 219845 1408 85166 141067 68113 1 79117 0 38908 17348 86376 0 101509 163083 1 512984 58265 197945 26066 61519 28764 11569 1940 4613 73675 901839 174413 24318 606 89271 1305234 1332 11502 155234 11118 23399 24408 9...
result:
wrong answer 1st numbers differ - expected: '51699', found: '51537'