QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#97089 | #5608. Determining Nucleotide Assortments | Nicolas125841 | AC ✓ | 365ms | 70708kb | Java11 | 1.6kb | 2023-04-16 15:16:23 | 2023-04-16 15:16:27 |
Judging History
answer
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
char[] line = br.readLine().toCharArray();
int[][] psum = new int[line.length][4];
for(int i = 0; i < line.length; i++) {
if(i > 0)
for(int j = 0; j < 4; j++)
psum[i][j] = psum[i-1][j];
psum[i][weight(line[i])]++;
}
int q = Integer.parseInt(br.readLine());
while(q --> 0) {
StringTokenizer st = new StringTokenizer(br.readLine());
int s = Integer.parseInt(st.nextToken())-1;
int e = Integer.parseInt(st.nextToken())-1;
ArrayList<int[]> clist = new ArrayList<>();
for(int i = 0; i < 4; i++) {
clist.add(new int[] {psum[e][i] - (s > 0 ? psum[s-1][i] : 0), i});
}
clist.sort(new Comparator<int[]>() {
@Override
public int compare(int[] a, int[] b) {
// TODO Auto-generated method stub
if(a[0] == b[0])
return Integer.compare(a[1], b[1]);
return Integer.compare(b[0], a[0]);
}
});
clist.forEach(v -> pw.print(unweight(v[1])));
pw.println();
}
pw.close();
}
static int weight(char c) {
if(c == 'A')
return 0;
else if(c == 'T')
return 1;
else if(c == 'G')
return 2;
else
return 3;
}
static char unweight(int n) {
if(n == 0)
return 'A';
else if(n == 1)
return 'T';
else if(n == 2)
return 'G';
else
return 'C';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 43ms
memory: 52060kb
input:
TATATGCTCT 3 1 10 6 10 6 6
output:
TACG TCGA GATC
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 365ms
memory: 70708kb
input:
CAGCCTAGAGTGGCAGTACCTTGACGACCAAGTGGGCAGTATCAGATTTTGACAGTATTCTATTGGATCTCCGTTACTACAGTCCATAGATTTTCCAACACGATCGGGGTTCTAGGGGAGGTTGAATCAAACTGGTGAGGTTTACACTCGAAGCAATGGCCACGACGGTTTCCGGATCGGCGGTAAGATTGGTAGGATCAAGTAGGAAAGACCGCTCTATTCTTTCCAATACCCTAAAACGGATACCCGCGGTTCTTGCATTGACGGAGGCAATACCGCAGCCTACGAAACTGTATTTGT...
output:
AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGCT AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC AGTC ...
result:
ok 25000 lines
Test #3:
score: 0
Accepted
time: 251ms
memory: 59736kb
input:
GGTGTGAAGGCGCACTACTGCCGTACGTCGACAGCCCAGATACATAAAGGACATACCTCGCCTTTCCAGCTTTACACCTTCAGAGTCGAAGCTGGTGTAAGACCAGCTGTCCTATCTGTCCCCATTTTGCAGGAGACGGAGTGCGACGGGCTGAGTTATGCGGGATTCAGATGCTTATTACAACTTGGGGGCTATGAAAACCTGGTAAGAGATAGAAGCTCCGCCCCCGACCTTATGACACCAGACCAGCGCCTGGTACACGGATCGAGCGGTGATATTTCCACTAAATTCAAGAAGCCA...
output:
CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT CGAT ...
result:
ok 10000 lines
Test #4:
score: 0
Accepted
time: 237ms
memory: 60136kb
input:
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
output:
TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC TAGC ...
result:
ok 10000 lines
Test #5:
score: 0
Accepted
time: 68ms
memory: 52500kb
input:
A 1 1 1
output:
ATGC
result:
ok single line: 'ATGC'
Test #6:
score: 0
Accepted
time: 68ms
memory: 51904kb
input:
T 1 1 1
output:
TAGC
result:
ok single line: 'TAGC'
Test #7:
score: 0
Accepted
time: 68ms
memory: 52056kb
input:
G 1 1 1
output:
GATC
result:
ok single line: 'GATC'
Test #8:
score: 0
Accepted
time: 54ms
memory: 52060kb
input:
C 1 1 1
output:
CATG
result:
ok single line: 'CATG'
Test #9:
score: 0
Accepted
time: 49ms
memory: 52376kb
input:
AAAAAAAAAAAA 1 1 12
output:
ATGC
result:
ok single line: 'ATGC'
Test #10:
score: 0
Accepted
time: 59ms
memory: 52332kb
input:
TTTTTTTTTTTT 1 1 12
output:
TAGC
result:
ok single line: 'TAGC'
Test #11:
score: 0
Accepted
time: 68ms
memory: 52188kb
input:
GGGGGGGGGGGG 1 1 12
output:
GATC
result:
ok single line: 'GATC'
Test #12:
score: 0
Accepted
time: 55ms
memory: 54072kb
input:
CCCCCCCCCCCC 1 1 12
output:
CATG
result:
ok single line: 'CATG'
Test #13:
score: 0
Accepted
time: 53ms
memory: 52180kb
input:
TTTTTTAAAAAA 1 1 12
output:
ATGC
result:
ok single line: 'ATGC'
Test #14:
score: 0
Accepted
time: 67ms
memory: 52324kb
input:
GGGGGGAAAAAA 1 1 12
output:
AGTC
result:
ok single line: 'AGTC'
Test #15:
score: 0
Accepted
time: 78ms
memory: 48224kb
input:
CCCCCCAAAAAA 1 1 12
output:
ACTG
result:
ok single line: 'ACTG'
Test #16:
score: 0
Accepted
time: 60ms
memory: 51964kb
input:
GGGGGGTTTTTT 1 1 12
output:
TGAC
result:
ok single line: 'TGAC'
Test #17:
score: 0
Accepted
time: 57ms
memory: 52284kb
input:
CCCCCCTTTTTT 1 1 12
output:
TCAG
result:
ok single line: 'TCAG'
Test #18:
score: 0
Accepted
time: 52ms
memory: 52440kb
input:
CCCCCCGGGGGG 1 1 12
output:
GCAT
result:
ok single line: 'GCAT'
Test #19:
score: 0
Accepted
time: 54ms
memory: 52160kb
input:
GGGGTTTTAAAA 1 1 12
output:
ATGC
result:
ok single line: 'ATGC'
Test #20:
score: 0
Accepted
time: 61ms
memory: 52180kb
input:
CCCCTTTTAAAA 1 1 12
output:
ATCG
result:
ok single line: 'ATCG'
Test #21:
score: 0
Accepted
time: 49ms
memory: 50336kb
input:
CCCCGGGGAAAA 1 1 12
output:
AGCT
result:
ok single line: 'AGCT'
Test #22:
score: 0
Accepted
time: 54ms
memory: 52492kb
input:
CCCCGGGGTTTT 1 1 12
output:
TGCA
result:
ok single line: 'TGCA'
Test #23:
score: 0
Accepted
time: 68ms
memory: 52320kb
input:
CCCGGGTTTAAA 1 1 12
output:
ATGC
result:
ok single line: 'ATGC'
Test #24:
score: 0
Accepted
time: 71ms
memory: 52284kb
input:
TGGTTAGAGGCGCCGACTTTCAGACGAATGTAAAGTGGAACCTCACTCCTATCGAAATAAGCAGAATCGGAGCTGGCTTGTTGGTCGAACGGAGCCCGTGTGCGGTCTTACGTAGCTCCATGAATCTGGGGATCAGGAGTGTGAACAGTCTCGGAAAACATACGTTGTTAATGTTGGCGACGTATGCCTATACCCAGCAGGCGACCAAGGGGGCAGACAAAGAGAATGGAGGGGCACCGTTACGCTTGAACGGCGACCGCGCTCGGAAACTCGAGTAGCCTTTGCGCATTACTTTTCAGT...
output:
GTCA GATC GACT TGCA AGCT TGCA TGCA GACT GCAT CAGT
result:
ok 10 lines
Test #25:
score: 0
Accepted
time: 75ms
memory: 52304kb
input:
GGGTTCGTCCAAAGCCCAGACATATCTCCCCATGATCGCAGTCGGGATGGCTTAATTCTACGCTGTCGTTCTCAATATTATTTTCGCTCAGGACTCAACGGAATCCTGGCTGTATTCAACACGACAAAGAAGGTACCCCCGCTCTTCGATTCCTTGCTGACAACTTAGCCGGCCGGAAAGCGGCCTCCGGTCGTCAATCTTGCACCTGAAGGAAACCTATACCTGCTACCACGTATGATACTCTAATCTCATTTCGGCACTGTCGTTGTTAGTGTGTGTTGTTGCGACCTGGTGGTCGAA...
output:
CGTA ATGC CAGT GCAT CGAT CAGT ACGT CGAT CAGT CGAT
result:
ok 10 lines
Test #26:
score: 0
Accepted
time: 83ms
memory: 53976kb
input:
AGCTTATCAAATACTGGCCCTAAGCTGATCCTTTAAGCGACAGTTTTGCCGACATTTACTCAAGACATCAGAGGACCGGCACAGGTCCACGCTGATTTCTAGGATACGATTCGGCCATCCGAAATAGATGTGTTACTAAGAGGGGGCCTTGGGTTCCACATGAAATCGGCGATTCCAATGAATAATAGGGACTTCCGAGATTCTCGCAGGGCAAGGGCAGAAAAACCTAAATGACCCCCAACCCTGCTAATTTCAGAACGATATGGTATCTCTACTGTATTAATCTACCGGACGCGAACT...
output:
ATGC GTCA GTCA CGTA ATCG CGTA CGTA CGTA GCTA GACT
result:
ok 10 lines
Test #27:
score: 0
Accepted
time: 81ms
memory: 52352kb
input:
ATGCGGTTTTACTGGAAGGGTATCCCACTTAGGTAATATGCATGTGAGATAACAAAAGTCAACGCATAGTTATTAATTAACGCTGGATAGAAAGCGAGAGGTACGAAATGTATGTGCTATGTGATCCTTAGCTAGTACTCCGAAGACGGTTAATTGATTCAGGTACCCTTTAGCAAAACTGACCGTAAAGGAGAGAAGGACAAGCCTGGGGCGAATCGTCCCCGTGACGGATATAGCAACATTACACGTTTATATCCGAGGTAGTATCGGCTGATACATGCTATTGATGTAGCATTTCGA...
output:
TGAC ATGC TACG ACTG GTAC TCGA TACG TAGC TACG TACG
result:
ok 10 lines
Test #28:
score: 0
Accepted
time: 61ms
memory: 52384kb
input:
ATTTAGTTCTCGGTGGCTAAATCTGTATCACTGTTACACCTTCCAAATTAAATGAGCGCCGCTTTAGTCGATTTAATGGTATATCTAACAAACATTACCGCGGAGTTGCTACGGGGAAGGATAGCGTGCCAACCACCATGGCAGCACTAACAGTGCTCGGGAGTCGGACAGGGTAACTGTGCCAAATCCCGTCGTGTGCGTTTACATCCACCCCCCTGAACCGATTTAAGTGACCTTTATTTATCACGACCAACGCGTCTGCTCTGGGGCCCATTAAGCTGCAACGCGGATAGATGCTCC...
output:
TACG TCAG TAGC TCAG TGCA ATCG TCGA TCAG GACT TGAC
result:
ok 10 lines
Test #29:
score: 0
Accepted
time: 65ms
memory: 52536kb
input:
TGCGTCCCCTGGCTAAGTGATAGGATAATCTCCATATCGCGTTGTATAGGATGCACTAAGTGTACCACAACACGATGCACCTGAGCATGAAGAAGTTGAGACTGAGTTATCGCAGAGAACTCGGCCTTTCTCCAGCCCGGCGTGCGAGAGGCACGACCGCAATATTTGACCCGCTGGTAACAGAAGACTTAGCTCCAAGGTGAGAACTGCCCTGGGATTAGTCCAGGGTGATTGTGCGCCCTCCACCCGACCCGCATTTCGTCAAATGGACGTAACACATTAACATTTGGTGACGGCCAA...
output:
TCGA TCGA TCGA TCGA TGCA TGCA TCGA CTGA TACG TCGA
result:
ok 10 lines
Test #30:
score: 0
Accepted
time: 54ms
memory: 53984kb
input:
CAACTGCAGCCCTTTAACCGAGCCCAGAGGAGGATTACAAGCTTTCGTCAGGTGCGACTCCAAACGTTACGCGGTATGGCTTTCCTAAGTCCAGTCCCCGCGTAAGCGGCAGTAATCAGTTGCGTTGGCCAACAGCCTGGCCGGCACTTCCTCTCTCTTGACATAGGGTCAAGCAGTTGGCGATTCATGTAACTTCTAGCTACCAGGCGCCTCAATCGGGAAACTCTGGAGTGACGACAGCACGTAGCTTCTTAGTATGGAACAGGATATGGAAATTGGCCAGAATTCCTGTTTACGACT...
output:
GTCA CTAG ATCG CTAG GTAC CTAG CGTA CATG CTAG TACG
result:
ok 10 lines
Test #31:
score: 0
Accepted
time: 69ms
memory: 52488kb
input:
AGGTTATGCCCACGAAGTCCAGATGTGCTCAGTACGCATCATACGCTCGCTCGGGCCTTTGGTTCCACGCGGACGTCATCTTGTGCGGGGAGTAAAGTTATCTTTTCCCGTCTTCGTTACACGTACCATTCGGCCCACTTGTACTGCGGCATCCATCTGGAAAATGTACCGGGAGCAAACTATGGGGATCGGCCCCGACTTCATCCCCCGGGTAGGGCACACTCCAGTAGCAGAGGGTACCCTCGGCGCATCCACAATAGTCGGTCCCGACGTTACGGGACGGCATCCTGTCCCATCATA...
output:
CGTA TCGA TGCA CAGT TGCA GCAT CGTA CGTA CGTA CGAT
result:
ok 10 lines
Test #32:
score: 0
Accepted
time: 94ms
memory: 56628kb
input:
TCGATACATTTATGTTTGCCGTCTTACTCCCCTCTGGTGTCCGTTCGATCGGGGATCGTCACTTGTTCTGCTAAAGAGTCTCGGGATTGGTTGAAAGTACAGCTCAGGTGTAACTAGTGGCCGGCTCGAGATAACTGCCAAATCTCTATTCCCTTGACAACTCACTAAGACAAGTTAACGGGACGTACGCGAGTATGCACAGTTAATGATTACCGGAAACGAATCTGTCCCAGACCGGCCCGATCGAACTTAAAGTGCGAATACGTAATAATTCTTACCTTTCAGGGTTATTGGATCTGA...
output:
ATCG ATGC TAGC GCTA GATC GACT CGAT TGAC GTAC GATC
result:
ok 10 lines
Test #33:
score: 0
Accepted
time: 64ms
memory: 54084kb
input:
ACTCGACAATTAGAGTCTAATAGACCGGGACAGAGTTGTGGACTAGAGACAAATCTAAAAGGCGTGTGCGCCCAGGGTTGCCTCCAGTCAGTCCGTGTCGTACCCTAGTAGCTCTAGCCAAGAATTCATTGTTGTGGCTTCACCTCGACAAGACGCCTTCCAAGATGCGGGTGTAATAGGATCGGGCACAATCGCTTTTCGGCTTGACAATCGGATAGAGCGTTGCTAGCCGGTCTGTCTGATCGATAACTACTTCGAAAAGCCCTACCAGGCGATGGGTGGTAATTTTTTAATATTCAA...
output:
ATCG ATCG AGCT AGCT ATCG AGTC AGTC CGAT GTCA GCAT
result:
ok 10 lines