QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#626835 | #7006. Rikka with Subsequences | tarjen | AC ✓ | 486ms | 3944kb | C++20 | 1.3kb | 2024-10-10 13:27:18 | 2024-10-10 13:27:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
void add(int &x,int y){
if((x+=y)>=mod)x-=mod;
}
int solve()
{
int n;cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a[i],a[i]--;
vector<vector<pair<int,int>>> p(n);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)if(a[i]==a[j])p[a[i]].emplace_back(i,j);
}
vector<string> s(n);
for(int i=0;i<n;i++)cin>>s[i];
vector<vector<int>>val(n,vector<int>(n));
for(int i=0;i<n;i++){
vector<vector<int>>now(n,vector<int>(n));
for(int j=0;j<n;j++)if(s[j][a[i]]=='1'){
for(auto [x,y]:p[j])now[x][y]=val[x][y];
}
for(int j=0;j<n;j++){
for(int k=1;k<n;k++){
add(now[j][k],now[j][k-1]);
}
}
for(int j=1;j<n;j++){
for(int k=0;k<n;k++)add(now[j][k],now[j-1][k]);
}
for(auto [x,y]:p[a[i]]){
add(val[x][y],1);
if(x>0&&y>0)add(val[x][y],now[x-1][y-1]);
}
}
int ans=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)add(ans,val[i][j]);
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T;cin>>T;while(T--)cout<<solve()<<"\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
1 4 1 2 1 2 1111 1111 1111 1111
output:
51
result:
ok single line: '51'
Test #2:
score: 0
Accepted
time: 486ms
memory: 3944kb
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