QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#744646 | #7006. Rikka with Subsequences | mayunfei | AC ✓ | 1266ms | 68476kb | C++17 | 1.6kb | 2024-11-13 22:42:05 | 2024-11-13 22:42:05 |
Judging History
answer
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#define ll long long
#define ull unsigned long long
#define lll __int128
#define pc __builtin_popcount
#define pr pair<int,int>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define lb(x) x&-x
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll rint(ll l,ll r){return uniform_int_distribution<ll>(l,r)(rnd);}
const int maxn=202,p=1e9+7;
void read(int &X)
{
X=0;
bool fu=0;
char cr=getchar();
while((cr<'0'||cr>'9')&&cr!='-') cr=getchar();
if(cr=='-') cr=getchar(),fu=1;
while(cr>='0'&&cr<='9') X=(X<<3)+(X<<1)+(cr^48),cr=getchar();
X=(fu?-X:X);
}
int T,n,a[maxn],ans,f[maxn][maxn][maxn],S[maxn][maxn][maxn],G[maxn][maxn];
char M[maxn][maxn];
int main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
read(T);
while(T--)
{
memset(f,0,sizeof(f)),memset(S,0,sizeof(S));
ans=0;
read(n);
for(int i=1;i<=n;i++) read(a[i]);
for(int i=1;i<=n;i++) scanf("%s",&M[i][1]);
for(int i=1;i<=n;i++)
{
memset(G,0,sizeof(G));
for(int j=1;j<=n;j++)
{
for(int k=1;k<=n;k++)
{
S[i][j][k]=(S[i-1][j][k]+f[i-1][j][k])%p;
G[j][k]=(1ll*G[j-1][k]+G[j][k-1]-G[j-1][k-1]+1ll*(M[a[j]][a[i]]-'0')*S[i][j][k]+p)%p;
}
}
for(int j=1;j<=n;j++)
for(int k=1;k<=n;k++)
f[i][j][k]=(a[i]==a[j]&&a[j]==a[k])*(1ll+G[j-1][k-1])%p,ans=(ans+f[i][j][k])%p;
}
printf("%d\n",ans);
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 68320kb
input:
1 4 1 2 1 2 1111 1111 1111 1111
output:
51
result:
ok single line: '51'
Test #2:
score: 0
Accepted
time: 1266ms
memory: 68476kb
input:
20 195 4 5 4 3 2 4 3 5 1 5 4 3 4 3 1 5 4 4 5 2 2 2 2 4 1 5 3 4 1 1 1 2 1 1 5 5 4 5 4 5 5 4 5 2 1 2 5 4 5 1 1 3 1 2 2 3 3 5 2 3 3 1 4 4 2 4 2 4 3 4 1 1 1 4 3 5 1 1 3 2 2 5 1 3 1 5 1 5 5 3 5 3 3 2 5 1 3 2 4 1 5 5 1 3 3 2 4 2 3 3 3 4 1 3 3 3 5 5 1 1 4 2 5 1 2 5 4 3 5 1 5 5 5 4 2 2 5 3 2 3 4 1 3 2 1 5 3...
output:
806298135 541285042 48173297 222851978 875793336 100057791 156057874 129923599 551277543 874547790 544405786 653241411 521317929 370918040 803940504 969296122 806596012 469227084 338962879 194278629
result:
ok 20 lines