QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748434 | #7006. Rikka with Subsequences | starback24 | AC ✓ | 1455ms | 4660kb | C++14 | 1.9kb | 2024-11-14 20:23:38 | 2024-11-14 20:23:38 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define fir first
#define sec second
#define file(__a) freopen(__a".in","r",stdin),freopen(__a".out","w",stdout);
#define look_time cerr<<(clock()-Time)/1000.0<<"s"<<endl
#define look_memory cerr<<(&b2-&b1)/1024.0/1024.0<<"MB"<<endl
using namespace std;
bool b1;
time_t Time = clock();
int T = 1;
template<typename T>
inline void read(T &s) {
T f = 1, c = 0;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') {
f = -1;
}
ch = getchar();
}
while (isdigit(ch)) {
c = (c << 1) + (c << 3) + (ch ^ 48);
ch = getchar();
}
s = f * c;
}
template<typename T, typename ...Args>
inline void read(T &s, Args &...args) {
read(s), read(args...);
}
namespace white_carton {
const int mod = 1000000007;
int n, a[210], dp[210][210], s[210][210];
char m[210][210];
void Solve() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
cin >> (m[i] + 1);
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
s[i][j] = dp[i][j] = 0;
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= n; k++) {
s[j + 1][k + 1] = (m[a[j]][a[i]] - '0') ? dp[j][k] : 0;
s[j + 1][k + 1] += ((s[j][k + 1] + s[j + 1][k]) % mod + mod - s[j][k]) % mod;
s[j + 1][j + 1] %= mod;
}
}
for (int j = 1; j <= n; j++) {
for (int k = 1; k <= n; k++) {
if (a[i] == a[j] && a[j] == a[k]) {
ans += s[j][k] + 1;
ans %= mod;
dp[j][k] += s[j][k] + 1;
dp[j][k] %= mod;
}
}
}
}
cout << (ans + mod) % mod << endl;
}
}
bool b2;
signed main() {
// file("dis");
cin >> T;
while (T--)white_carton::Solve();
look_time;
look_memory;
}
//日拱一卒,功不唐捐
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4028kb
input:
1 4 1 2 1 2 1111 1111 1111 1111
output:
51
result:
ok single line: '51'
Test #2:
score: 0
Accepted
time: 1455ms
memory: 4660kb
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