QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#93089 | #6175. 遗传密码问题 | Renshey | 0 | 1617ms | 16880kb | C++23 | 1.5kb | 2023-03-31 10:45:25 | 2023-03-31 10:45:27 |
Judging History
answer
#include <bits/stdc++.h>
int map (char c)
{
if (c == 'A') return 0;
if (c == 'C') return 0;
if (c == 'G') return 0;
if (c == 'T') return 0;
}
const long long inf = 1LL << 60;
const int maxn = 1 << 19;
struct Trie
{
int tot, ch[maxn][4]; long long min[maxn];
void build (void) {tot = 1;}
void clear (void) {for (int i = 1; i <= tot; i++) ch[i][0] = ch[i][1] = ch[i][2] = ch[i][3] = 0;}
} Tr[2];
int n, m, q; char S[maxn], T[maxn]; long long f[maxn];
void solve (void)
{
scanf("%s%d", S + 1, &q); n = strlen(S + 1);
Tr[0].build(); Tr[1].build();
for (int i = 1; i <= q; i++)
{
long long w; scanf("%s%lld", T + 1, &w); m = strlen(T + 1);
for (int j = 1, u = 1; j <= m; j++)
{
int &k = Tr[0].ch[u][map(T[j])];
if (!k) Tr[0].min[k = ++Tr[0].tot] = inf;
u = k; Tr[0].min[u] = std::min(Tr[0].min[u], w);
}
for (int j = m, u = 1; j >= 1; j--)
{
int &k = Tr[1].ch[u][map(T[j])];
if (!k) Tr[1].min[k = ++Tr[1].tot] = inf;
u = k; Tr[1].min[u] = std::min(Tr[1].min[u], w);
}
}
for (int i = 1; i <= n; i++) f[i] = inf;
for (int i = 0; i <= n; i++)
{
for (int u = 1, j = i; j >= 1 and Tr[1].ch[u][map(S[j])]; j--) f[i] = std::min(f[i], f[j - 1] + Tr[1].min[u = Tr[1].ch[u][map(S[j])]]);
for (int u = 1, j = i + 1; j <= n and Tr[0].ch[u][map(S[j])]; j++) f[j] = std::min(f[j], f[i] + Tr[0].min[u = Tr[0].ch[u][map(S[j])]]);
}
printf("%lld\n", f[n] == inf ? -1 : f[n]);
Tr[0].clear(); Tr[1].clear();
}
signed main ()
{
int T;
for (scanf("%d", &T); T--; ) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 11812kb
input:
10 TGTTCTGAACCACCATGGTGTCCTTGACTAGGGTGCTAAACCAAATCCTGGGTAGCCCGAGAGCAGTACCCGAGCGCAGGGGACGTCCAAA 18 GAAACG 872707675 TACTT 679726598 GTAAA 723748135 TGACG 461452620 TAGACC 719002639 GAGTGT 398114360 CGTGAC 37546213 TGACAT 219353887 CGCGC 465810039 ATGCT 773690110 ATAC 303269549 GCTACC 622915976 TTCTAA...
output:
600739408 303018378 764829282 776308332 222671295 2291669358 72420689 572154739 702524762 1771877614
result:
wrong answer 1st numbers differ - expected: '6765079310', found: '600739408'
Test #2:
score: 0
Wrong Answer
time: 4ms
memory: 14064kb
input:
10 GGTCTAGAGTATAAAATACTAGTGAAAAGGTCAGACTTCGAGCTGGTGCTCAGAAGGGTTTGATGAAGTGCCAAACTACAATCCAAAGGTTAATTAGTTACACCTAAAGGCAGGACAGTTTTCGGCGGAATAACATTCGCACGTTGAATTATTTGGCTTAGCTTGACAGATAGGTCAGGAGTCACAAAAAGTGGCAGGATTGGATTGCATGTTAAAGCATAAGTGAGCGAGCCGGCACCCACGCGTGTGCTACGTTGCTCCACACAATGATGAGCGCGTTCCAGGAATCTCAACCTG...
output:
657820746 133730051 1051544578 497173424 658942722 650849376 371267532 2014115775 858811149 288838068
result:
wrong answer 1st numbers differ - expected: '149102664725', found: '657820746'
Test #3:
score: 0
Wrong Answer
time: 10ms
memory: 11760kb
input:
10 AGATTCTAGTCGATCGTCATCATATGCTCGTGGTGTATGCCAACGCCCCCGTGTCCTGGAACATAAACAAACTATCTCGAAACGTCAACGGGATGACTTAACGACCGATCGTGACGATACCAGAAGGGCTATAGACACAGTGACTAATTATCCTACCAAACTTTATGTGCGACGTGACCGTAACGGGATTGCCACTCTTCCTGCCAGGGGTACCCCTTACAGATTGTTGACGCACATTTTATATGGACCTACTTTCAAGAGTGGACATCTTCGGAGATTCCGGACCGGACAATGTCC...
output:
1032716790 1056290400 3750082326 954657492 1874256129 4066640254 2012775941 47637095 140051466 642667848
result:
wrong answer 1st numbers differ - expected: '235746326088', found: '1032716790'
Test #4:
score: 0
Time Limit Exceeded
input:
10 GTGTTGGCAAAGAATGCAGCAGCTTATTAAGCCGAAAGTGATCAGCGGGGCTAAATGACCGTAATCGGGGCGACTCGAACACACACTCGCGGCCGGCCAAGAACCTGAACCACCGGAAGTTCAGCCTTTCTTCGAGAAATCGTGCATCACATTATAATAACCACCCTCTATGCACTGCGGGGGCCTTACAAGCTCTCGGGCTATCGGAATAGAGTCGTGCACACCATATTAGTGCTCGAACTACTACTTGAAAGCCGCAAGGCAGGCCGCCTATAGAGTTAGTACACAAAACAATAC...
output:
result:
Test #5:
score: 0
Wrong Answer
time: 1617ms
memory: 12428kb
input:
5 TTTGCTTTGGCCTTTATGGGCGACCCTATGAGCACAGGCACAACTGAGTTCAGCCAATGCTAGGTGATGCATAGGGTAGTGAGCCTCGCGCATCTTGGGATTACCAACCCAGACCCTGTCTAATGCCATCCATGTCTCATATCTGCTAACCTCCTAAGGCTGCTGCCATCTGTATCAATATTGGTGCTAAACTTAGCTTGAGGCGTGAGGGTCCTATTGTATACGTGATCTAGCCAGTGTAATAACGAGTCAACGTTCATCTGTGGAGAAAGACACTCTTCAATTTGGATGGGCCGGG...
output:
1280951993 286231539 2952671800 393927424 90677106
result:
wrong answer 1st numbers differ - expected: '1518565725323', found: '1280951993'
Test #6:
score: 0
Time Limit Exceeded
input:
5 TATTCTACTAGCTGAAGTACCGTGCTTCGTGATAATGGTCAGCACACCTTGAAGGCGCCTGTTTGCACAGCCTTGCGTCTGGCGCTTAGTCTCGACCCTGATGCGGAGGATCTTTTCACGATATATATGGTACAGTTATGGTTACTTATTGAGCCCGTATTTGCTATGTCAGTTAAGTCTTGCGTGGCTGTATTCCTCGAGGCGAACAAGTCATTCAACACAACATCAGGGGTGAGGCTTCTCAGCGCCCAGAAAAAACGCTAGCTACGGGGTATCTTAATATAGGCTAGTGAAGGTG...
output:
result:
Test #7:
score: 0
Wrong Answer
time: 224ms
memory: 14628kb
input:
3 GGTTTTCGCGCGTGTCATGAACCAGCATACGCCAGATGGAACACGGTTTAAGGGCGGGAGTTACCTTTAGGCGCATGCTGGACATCTTGAACCCGTTCCTCAGGCGGGGTTGCGAATAAAGAGTTGCAACCCCCTCCACGACCACACGATCAAGAACGATTAATATAATACGAACCCCACTAACAGGAGATCTATCTGGCAGATCTCTCCAATGTGTGACCAGTTCTAGTGGAACCGGGATGATAGACACAATGAAAGGCGGTTGTGACTTTATTAAACAACACAGTCATGTCGTTTG...
output:
596947680 1085804856 9365144
result:
wrong answer 1st numbers differ - expected: '355869773343', found: '596947680'
Test #8:
score: 0
Wrong Answer
time: 364ms
memory: 12836kb
input:
3 TAGCGGGCCTTTTTAAGATACTGGTGAAGGCTCGATCGACGGCTTTAATGGTATTGAAGTCGTTCGCCGTTGTCTTTATAACGCCCCGGATATGGCATCTTATAAGGTCAACAAATTGCACATATAAGCGGCTCCTCCCTTCTCTCAGTCAAGATGACTAAACCGCTGCTTACGAGCAGGAAGTCTTACGAATCCTAGTTATCCCCTACACCTTCTCCTGCTGCCTCAAGACCAGTACGGGTGAGCCATGCAGGAGATTTGAATCTTATTGAAAATAATCGCTGGAACAGAAACAGAT...
output:
3164906472 809574234 8027351748
result:
wrong answer 1st numbers differ - expected: '432921513168', found: '3164906472'
Test #9:
score: 0
Wrong Answer
time: 70ms
memory: 16212kb
input:
3 CAATTCCATGGCATCTGGCCGATAATTGACTCGATATCAGTGATCCAGCCAACTAGTGACGGCAGAGAACCGGACCCACTATGTGCATGTTGTGTGAGCAAGTCCCGTTCCTCGATCGCTTCTAGCAGAGCCGTCTTTAAACTGTATGTCTTCCCGTGCCCCCTAATTAAACCGGCCTTTCTTAACTACCGTTTGCGCAGTATCCGTGAGCGTTAGTGCCCGCAGGATTCTCCCCGAGGGCCCCTGAGCAGGTGATGCCAATGAGGCAAGAGCTCACGCTCGGCACAAAATGAAAGCG...
output:
673665650 814969056 4962042306
result:
wrong answer 1st numbers differ - expected: '32444137641', found: '673665650'
Test #10:
score: 0
Wrong Answer
time: 545ms
memory: 16880kb
input:
1 GGGGTATTAGCGTAAGTGTCAACCACTACAGTCAATGCTTACGGTAGAAGGTGGAATAGGACTTACAGCCCCCTCACCAACATGCCTTTTTTAAATTACGGCATCGATTGGGATTGCAATAATGCCCACTGAAGTCCAAGGGAGCGGGAGCGCTCTTTTACGTTGGGCACCATACCGTGTTCGTCAGAACCCCACGAGCTTCGATCTCTGTATATAAGTAATGGGAATCAGCAGGCGACCAGGGTCCGCTTTTGGTTCAAATCAAACGGTCACGTCTACATTGCAGGAGAGAAGTAAA...
output:
94397526
result:
wrong answer 1st numbers differ - expected: '161607544918', found: '94397526'