QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#325095#5608. Determining Nucleotide Assortmentsjhtang2AC ✓15ms4196kbC++141.1kb2024-02-11 04:13:102024-02-11 04:13:12

Judging History

你现在查看的是最新测评结果

  • [2024-02-11 04:13:12]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:4196kb
  • [2024-02-11 04:13:10]
  • 提交

answer

// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	string dna;
	cin >> dna;
	dna.insert(dna.begin(), ' ');
	int n = (int) dna.size() - 1;
	vector<int> preA(n + 1);
	vector<int> preT(n + 1);
	vector<int> preG(n + 1);
	vector<int> preC(n + 1);
	for (int i = 1; i < (int) dna.size(); i++) {
		preA[i] = preA[i - 1] + (dna[i] == 'A' ? 1 : 0);
		preT[i] = preT[i - 1] + (dna[i] == 'T' ? 1 : 0);
		preG[i] = preG[i - 1] + (dna[i] == 'G' ? 1 : 0);
		preC[i] = preC[i - 1] + (dna[i] == 'C' ? 1 : 0);
	}

	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		
		vector<pair<int, int>> vec = 
			{{preA[b] - preA[a - 1], 4}, {preT[b] - preT[a - 1], 3},
			{preG[b] - preG[a - 1], 2}, {preC[b] - preC[a - 1], 1}};
		sort(vec.begin(), vec.end(), std::greater<pair<int, int>>());

		for (int j = 0; j < 4; j++) {
			switch(vec[j].second) {
			case 4:
				cout << 'A';
				break;
			case 3:
				cout << 'T';
				break;
			case 2:
				cout << 'G';
				break;
			case 1:
				cout << 'C';
				break;
			}
		}

		cout << endl;
	}

}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3500kb

input:

TATATGCTCT
3
1 10
6 10
6 6

output:

TACG
TCGA
GATC

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 4ms
memory: 3924kb

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: 4ms
memory: 3580kb

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: 15ms
memory: 3680kb

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: 0ms
memory: 3576kb

input:

A
1
1 1

output:

ATGC

result:

ok single line: 'ATGC'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

T
1
1 1

output:

TAGC

result:

ok single line: 'TAGC'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

G
1
1 1

output:

GATC

result:

ok single line: 'GATC'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

C
1
1 1

output:

CATG

result:

ok single line: 'CATG'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

AAAAAAAAAAAA
1
1 12

output:

ATGC

result:

ok single line: 'ATGC'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

TTTTTTTTTTTT
1
1 12

output:

TAGC

result:

ok single line: 'TAGC'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

GGGGGGGGGGGG
1
1 12

output:

GATC

result:

ok single line: 'GATC'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

CCCCCCCCCCCC
1
1 12

output:

CATG

result:

ok single line: 'CATG'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

TTTTTTAAAAAA
1
1 12

output:

ATGC

result:

ok single line: 'ATGC'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3496kb

input:

GGGGGGAAAAAA
1
1 12

output:

AGTC

result:

ok single line: 'AGTC'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

CCCCCCAAAAAA
1
1 12

output:

ACTG

result:

ok single line: 'ACTG'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3500kb

input:

GGGGGGTTTTTT
1
1 12

output:

TGAC

result:

ok single line: 'TGAC'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

CCCCCCTTTTTT
1
1 12

output:

TCAG

result:

ok single line: 'TCAG'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

CCCCCCGGGGGG
1
1 12

output:

GCAT

result:

ok single line: 'GCAT'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

GGGGTTTTAAAA
1
1 12

output:

ATGC

result:

ok single line: 'ATGC'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

CCCCTTTTAAAA
1
1 12

output:

ATCG

result:

ok single line: 'ATCG'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

CCCCGGGGAAAA
1
1 12

output:

AGCT

result:

ok single line: 'AGCT'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3448kb

input:

CCCCGGGGTTTT
1
1 12

output:

TGCA

result:

ok single line: 'TGCA'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

CCCGGGTTTAAA
1
1 12

output:

ATGC

result:

ok single line: 'ATGC'

Test #24:

score: 0
Accepted
time: 1ms
memory: 4196kb

input:

TGGTTAGAGGCGCCGACTTTCAGACGAATGTAAAGTGGAACCTCACTCCTATCGAAATAAGCAGAATCGGAGCTGGCTTGTTGGTCGAACGGAGCCCGTGTGCGGTCTTACGTAGCTCCATGAATCTGGGGATCAGGAGTGTGAACAGTCTCGGAAAACATACGTTGTTAATGTTGGCGACGTATGCCTATACCCAGCAGGCGACCAAGGGGGCAGACAAAGAGAATGGAGGGGCACCGTTACGCTTGAACGGCGACCGCGCTCGGAAACTCGAGTAGCCTTTGCGCATTACTTTTCAGT...

output:

GTCA
GATC
GACT
TGCA
AGCT
TGCA
TGCA
GACT
GCAT
CAGT

result:

ok 10 lines

Test #25:

score: 0
Accepted
time: 1ms
memory: 4052kb

input:

GGGTTCGTCCAAAGCCCAGACATATCTCCCCATGATCGCAGTCGGGATGGCTTAATTCTACGCTGTCGTTCTCAATATTATTTTCGCTCAGGACTCAACGGAATCCTGGCTGTATTCAACACGACAAAGAAGGTACCCCCGCTCTTCGATTCCTTGCTGACAACTTAGCCGGCCGGAAAGCGGCCTCCGGTCGTCAATCTTGCACCTGAAGGAAACCTATACCTGCTACCACGTATGATACTCTAATCTCATTTCGGCACTGTCGTTGTTAGTGTGTGTTGTTGCGACCTGGTGGTCGAA...

output:

CGTA
ATGC
CAGT
GCAT
CGAT
CAGT
ACGT
CGAT
CAGT
CGAT

result:

ok 10 lines

Test #26:

score: 0
Accepted
time: 1ms
memory: 3700kb

input:

AGCTTATCAAATACTGGCCCTAAGCTGATCCTTTAAGCGACAGTTTTGCCGACATTTACTCAAGACATCAGAGGACCGGCACAGGTCCACGCTGATTTCTAGGATACGATTCGGCCATCCGAAATAGATGTGTTACTAAGAGGGGGCCTTGGGTTCCACATGAAATCGGCGATTCCAATGAATAATAGGGACTTCCGAGATTCTCGCAGGGCAAGGGCAGAAAAACCTAAATGACCCCCAACCCTGCTAATTTCAGAACGATATGGTATCTCTACTGTATTAATCTACCGGACGCGAACT...

output:

ATGC
GTCA
GTCA
CGTA
ATCG
CGTA
CGTA
CGTA
GCTA
GACT

result:

ok 10 lines

Test #27:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

ATGCGGTTTTACTGGAAGGGTATCCCACTTAGGTAATATGCATGTGAGATAACAAAAGTCAACGCATAGTTATTAATTAACGCTGGATAGAAAGCGAGAGGTACGAAATGTATGTGCTATGTGATCCTTAGCTAGTACTCCGAAGACGGTTAATTGATTCAGGTACCCTTTAGCAAAACTGACCGTAAAGGAGAGAAGGACAAGCCTGGGGCGAATCGTCCCCGTGACGGATATAGCAACATTACACGTTTATATCCGAGGTAGTATCGGCTGATACATGCTATTGATGTAGCATTTCGA...

output:

TGAC
ATGC
TACG
ACTG
GTAC
TCGA
TACG
TAGC
TACG
TACG

result:

ok 10 lines

Test #28:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

ATTTAGTTCTCGGTGGCTAAATCTGTATCACTGTTACACCTTCCAAATTAAATGAGCGCCGCTTTAGTCGATTTAATGGTATATCTAACAAACATTACCGCGGAGTTGCTACGGGGAAGGATAGCGTGCCAACCACCATGGCAGCACTAACAGTGCTCGGGAGTCGGACAGGGTAACTGTGCCAAATCCCGTCGTGTGCGTTTACATCCACCCCCCTGAACCGATTTAAGTGACCTTTATTTATCACGACCAACGCGTCTGCTCTGGGGCCCATTAAGCTGCAACGCGGATAGATGCTCC...

output:

TACG
TCAG
TAGC
TCAG
TGCA
ATCG
TCGA
TCAG
GACT
TGAC

result:

ok 10 lines

Test #29:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

TGCGTCCCCTGGCTAAGTGATAGGATAATCTCCATATCGCGTTGTATAGGATGCACTAAGTGTACCACAACACGATGCACCTGAGCATGAAGAAGTTGAGACTGAGTTATCGCAGAGAACTCGGCCTTTCTCCAGCCCGGCGTGCGAGAGGCACGACCGCAATATTTGACCCGCTGGTAACAGAAGACTTAGCTCCAAGGTGAGAACTGCCCTGGGATTAGTCCAGGGTGATTGTGCGCCCTCCACCCGACCCGCATTTCGTCAAATGGACGTAACACATTAACATTTGGTGACGGCCAA...

output:

TCGA
TCGA
TCGA
TCGA
TGCA
TGCA
TCGA
CTGA
TACG
TCGA

result:

ok 10 lines

Test #30:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

CAACTGCAGCCCTTTAACCGAGCCCAGAGGAGGATTACAAGCTTTCGTCAGGTGCGACTCCAAACGTTACGCGGTATGGCTTTCCTAAGTCCAGTCCCCGCGTAAGCGGCAGTAATCAGTTGCGTTGGCCAACAGCCTGGCCGGCACTTCCTCTCTCTTGACATAGGGTCAAGCAGTTGGCGATTCATGTAACTTCTAGCTACCAGGCGCCTCAATCGGGAAACTCTGGAGTGACGACAGCACGTAGCTTCTTAGTATGGAACAGGATATGGAAATTGGCCAGAATTCCTGTTTACGACT...

output:

GTCA
CTAG
ATCG
CTAG
GTAC
CTAG
CGTA
CATG
CTAG
TACG

result:

ok 10 lines

Test #31:

score: 0
Accepted
time: 1ms
memory: 3796kb

input:

AGGTTATGCCCACGAAGTCCAGATGTGCTCAGTACGCATCATACGCTCGCTCGGGCCTTTGGTTCCACGCGGACGTCATCTTGTGCGGGGAGTAAAGTTATCTTTTCCCGTCTTCGTTACACGTACCATTCGGCCCACTTGTACTGCGGCATCCATCTGGAAAATGTACCGGGAGCAAACTATGGGGATCGGCCCCGACTTCATCCCCCGGGTAGGGCACACTCCAGTAGCAGAGGGTACCCTCGGCGCATCCACAATAGTCGGTCCCGACGTTACGGGACGGCATCCTGTCCCATCATA...

output:

CGTA
TCGA
TGCA
CAGT
TGCA
GCAT
CGTA
CGTA
CGTA
CGAT

result:

ok 10 lines

Test #32:

score: 0
Accepted
time: 1ms
memory: 3760kb

input:

TCGATACATTTATGTTTGCCGTCTTACTCCCCTCTGGTGTCCGTTCGATCGGGGATCGTCACTTGTTCTGCTAAAGAGTCTCGGGATTGGTTGAAAGTACAGCTCAGGTGTAACTAGTGGCCGGCTCGAGATAACTGCCAAATCTCTATTCCCTTGACAACTCACTAAGACAAGTTAACGGGACGTACGCGAGTATGCACAGTTAATGATTACCGGAAACGAATCTGTCCCAGACCGGCCCGATCGAACTTAAAGTGCGAATACGTAATAATTCTTACCTTTCAGGGTTATTGGATCTGA...

output:

ATCG
ATGC
TAGC
GCTA
GATC
GACT
CGAT
TGAC
GTAC
GATC

result:

ok 10 lines

Test #33:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

ACTCGACAATTAGAGTCTAATAGACCGGGACAGAGTTGTGGACTAGAGACAAATCTAAAAGGCGTGTGCGCCCAGGGTTGCCTCCAGTCAGTCCGTGTCGTACCCTAGTAGCTCTAGCCAAGAATTCATTGTTGTGGCTTCACCTCGACAAGACGCCTTCCAAGATGCGGGTGTAATAGGATCGGGCACAATCGCTTTTCGGCTTGACAATCGGATAGAGCGTTGCTAGCCGGTCTGTCTGATCGATAACTACTTCGAAAAGCCCTACCAGGCGATGGGTGGTAATTTTTTAATATTCAA...

output:

ATCG
ATCG
AGCT
AGCT
ATCG
AGTC
AGTC
CGAT
GTCA
GCAT

result:

ok 10 lines