QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#748310 | #7006. Rikka with Subsequences | ciuim | AC ✓ | 837ms | 4704kb | C++14 | 2.1kb | 2024-11-14 19:59:29 | 2024-11-14 19:59:29 |
Judging History
answer
bool M1;
#define look_memory cerr<<abs(&M2-&M1)/1024.0/1024<<" MB\n"
#define look_time cerr<<(clock()-Time)*1.0/CLOCKS_PER_SEC<<'\n'
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <cstring>
#include <array>
#include <algorithm>
#include <queue>
#include <vector>
#include <bitset>
#include <ctime>
#include <cstdlib>
#include <random>
#include <set>
#include <ctime>
#include <map>
#include <stack>
#include <unordered_map>
#include <assert.h>
#include <unordered_set>
#define i128 __int128
#define ll long long
#define uint unsigned
#define ull unsigned long long
#define ld long double
#define fo(a,b,c) for(ll a=b;a<=c;++a)
#define re(a,b,c) for(ll a=b;a>=c;--a)
#define pii pair<ll,ll>
#define pdd pair<db,db>
#define fi first
#define pb push_back
#define se second
#define ite set<ll> ::iterator
#define vite vector<ll> ::iterator
using namespace std;
const ll mod=1e9+7;
inline ll gi()
{
ll x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x = (x<<1) + (x<<3) + (ch^48);
ch = getchar();
}
return x * f;
}
ll _=1;
const ll inf=2e17+5,iinf=1e9+5;
const ll N=205;
ll dp[N][N],sum[N][N],a[N];
char s[N][N];
void sol()
{
ll n=gi();
fo(i,1,n) a[i]=gi();
fo(i,1,n)
{
cin>>s[i]+1;
}
memset(dp,0,sizeof(dp));
fo(i,1,n)
{
memset(sum,0,sizeof(sum));
fo(j,1,n)
{
fo(k,1,n)
{
if(s[a[j-1]][a[i]]=='1')
{
sum[j][k]+=dp[j-1][k-1];
}
sum[j][k]+=sum[j-1][k];
sum[j][k]+=sum[j][k-1];
sum[j][k]-=sum[j-1][k-1];
sum[j][k]%=mod;
}
}
fo(j,1,n)
{
fo(k,1,n)
{
if(a[j]==a[i]&&a[j]==a[k])dp[j][k]+=sum[j][k]+1;
dp[j][k]%=mod;
}
}
}
ll ans=0;
fo(i,1,n)
{
fo(j,1,n)
{
ans+=dp[i][j];
ans%=mod;
}
}
ans+=mod;
ans%=mod;
cout<<ans;
}
bool M2;
int main()
{
int Time=clock();
look_memory;
_=gi();
while(_--)
{
sol();
printf("\n");
}
look_time;
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4624kb
input:
1 4 1 2 1 2 1111 1111 1111 1111
output:
51
result:
ok single line: '51'
Test #2:
score: 0
Accepted
time: 837ms
memory: 4704kb
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