QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#847456 | #9922. Mah-jong | fang_baby | WA | 2323ms | 3860kb | C++23 | 4.9kb | 2025-01-07 23:30:06 | 2025-01-07 23:30:07 |
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]==-6||num[j]==-3||num[j]==0){
num4[j] = -3;
}else{
num4[j] = num[j]%3;
}
}
int ok2 = 0;
int ok = 0;
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3860kb
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: 2323ms
memory: 3652kb
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:
52379 62906 4995 2063 244616 6507 11210 45796 435054 1218511 18121 140598 301138 963678 220468 1469 86690 142402 69426 1 79925 0 39396 17564 86830 0 101987 164092 3 515085 59164 198718 26742 62221 29227 11825 2185 4711 75218 910145 175703 24721 704 89800 1308273 1419 11884 156406 11663 23820 24889 1...
result:
wrong answer 1st numbers differ - expected: '51699', found: '52379'