QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#749905 | #7006. Rikka with Subsequences | mengzdd | AC ✓ | 1331ms | 4580kb | C++14 | 2.0kb | 2024-11-15 11:15:21 | 2024-11-15 11:15:23 |
Judging History
answer
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=(j);i<=(k);++i)
#define NFOR(i,j,k) for(int i=(j);i>=(k);--i)
#define mkp make_pair
#define fst first
#define sec second
#define inl inline
#define pb push_back
#define el_phy_kongroo return 0
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned int ui;
typedef pair< int,int > pii;
bool memst;
const int inf=0x3f3f3f3f;
const ll infll=0x3f3f3f3f3f3f3f3fll;
inl void telmem()
{
bool memed;
cerr<<(&memed-&memst)/1024.0/1024.0<<endl;
}
inl void teltim(int x)
{
clock_t c1=0;
if(x) c1=clock();
else cerr<<endl<<clock()-c1<<"ms"<<endl;
}
void file()
{
freopen(".in","r",stdin);
freopen(".out","w",stdout);
}
inl int read()
{
int s=0,w=1; char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar();}
while(ch>='0'&&ch<='9') {s=(s<<1)+(s<<3)+ch-'0',ch=getchar();}
return s*w;
}
namespace wheelchair
{
const ll mod=1e9+7;
inl ll addmod(ll x,ll y) {return ((ll)x+y)%mod;}
inl ll mulmod(ll x,ll y) {return 1ll*x*y%mod;}
inl ll delmod(ll x,ll y) {return (x-y+mod)%mod;}
inl void addchg(ll &x,ll y) {x=(x+y)%mod;}
inl void mulchg(ll &x,ll y) {x=(1ll*x*y)%mod;}
inl void delchg(ll &x,ll y) {x=(x-y+mod)%mod;}
}
using namespace wheelchair;
const int N=205;
int n;
char s[N][N];
ll a[N],dp[N][N],g[N][N];
void sov()
{
memset(dp,0,sizeof(dp));
n=read();
FOR(i,1,n) a[i]=read();
FOR(i,1,n) scanf("%s",s[i]+1);
FOR(i,1,n)
{
memset(g,0,sizeof(g));
FOR(j,1,n) FOR(k,1,n) g[j][k]=((g[j-1][k]+g[j][k-1]-g[j-1][k-1]+dp[j-1][k-1]*(s[a[j-1]][a[i]]^48))%mod+mod)%mod;
FOR(j,1,n) FOR(k,1,n) dp[j][k]=(dp[j][k]+(g[j][k]+1)*(a[i]==a[j])*(a[i]==a[k]))%mod;
}
ll ans=0;
FOR(j,1,n) FOR(k,1,n) addchg(ans,dp[j][k]);
printf("%lld\n",ans);
}
int main()
{
//file();
int _=read();
while(_--) sov();
el_phy_kongroo;
}
/*
???????
?? ??????
? ? ?? ?AK???
? ??? NOIP? SDOI??
? ?????????NOI ??
????????????? ??
???????????? ???
??????????? ????
??????? ????
????????????
?????????
???????????????
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4452kb
input:
1 4 1 2 1 2 1111 1111 1111 1111
output:
51
result:
ok single line: '51'
Test #2:
score: 0
Accepted
time: 1331ms
memory: 4580kb
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