QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#681248#5608. Determining Nucleotide Assortmentsvic233333#AC ✓19ms4644kbC++201.5kb2024-10-27 03:35:132024-10-27 03:35:14

Judging History

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

  • [2024-10-27 03:35:14]
  • 评测
  • 测评结果:AC
  • 用时:19ms
  • 内存:4644kb
  • [2024-10-27 03:35:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define pb push_back

const ld pi = 3.14159265358979323846;
const int mod = 998244353;
const ll INF = 1e18;

template<typename T>
T chmax(T a, T b) {
    return a > b ? a : b;
}

template<typename T>
T chmin(T a, T b) {
    return a > b ? b : a;
}

const int N = (int)1e5 + 1, M = N * 2;

void solve(){
    string s;
    cin >> s;

    int n = s.length(), m;
    cin >> m;

    int f[n + 1][4];
    memset(f, 0, sizeof f);

    map<char, int> mp;
    mp['A'] = 0;
    mp['T'] = 1;
    mp['G'] = 2;
    mp['C'] = 3;

    map<int, int> rec;
    rec[0] = 'A';
    rec[1] = 'T';
    rec[2] = 'G';
    rec[3] = 'C';

    for(int i = 1; i <= n; i++){
        f[i][mp[s[i - 1]]]++;
        for(int j = 0; j < 4; j++){
            f[i][j] += f[i - 1][j];
        }
    }

    while(m--){
        int l, r;
        cin >> l >> r;

        vector<vector<int>> b;

        for(int i = 0; i < 4; i++){
            b.pb({-(f[r][i] - f[l - 1][i]), i});
        }

        sort(b.begin(), b.end());
        string s = "";
        for(int i = 0; i < 4; i++){
            s += rec[b[i][1]];
        }
        cout << s << endl;
    }
}

int main() {
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
//    cin >> t;

    while(t--){
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

TATATGCTCT
3
1 10
6 10
6 6

output:

TACG
TCGA
GATC

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 19ms
memory: 4644kb

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: 3ms
memory: 3984kb

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: 11ms
memory: 3876kb

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: 3472kb

input:

A
1
1 1

output:

ATGC

result:

ok single line: 'ATGC'

Test #6:

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

input:

T
1
1 1

output:

TAGC

result:

ok single line: 'TAGC'

Test #7:

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

input:

G
1
1 1

output:

GATC

result:

ok single line: 'GATC'

Test #8:

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

input:

C
1
1 1

output:

CATG

result:

ok single line: 'CATG'

Test #9:

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

input:

AAAAAAAAAAAA
1
1 12

output:

ATGC

result:

ok single line: 'ATGC'

Test #10:

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

input:

TTTTTTTTTTTT
1
1 12

output:

TAGC

result:

ok single line: 'TAGC'

Test #11:

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

input:

GGGGGGGGGGGG
1
1 12

output:

GATC

result:

ok single line: 'GATC'

Test #12:

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

input:

CCCCCCCCCCCC
1
1 12

output:

CATG

result:

ok single line: 'CATG'

Test #13:

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

input:

TTTTTTAAAAAA
1
1 12

output:

ATGC

result:

ok single line: 'ATGC'

Test #14:

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

input:

GGGGGGAAAAAA
1
1 12

output:

AGTC

result:

ok single line: 'AGTC'

Test #15:

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

input:

CCCCCCAAAAAA
1
1 12

output:

ACTG

result:

ok single line: 'ACTG'

Test #16:

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

input:

GGGGGGTTTTTT
1
1 12

output:

TGAC

result:

ok single line: 'TGAC'

Test #17:

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

input:

CCCCCCTTTTTT
1
1 12

output:

TCAG

result:

ok single line: 'TCAG'

Test #18:

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

input:

CCCCCCGGGGGG
1
1 12

output:

GCAT

result:

ok single line: 'GCAT'

Test #19:

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

input:

GGGGTTTTAAAA
1
1 12

output:

ATGC

result:

ok single line: 'ATGC'

Test #20:

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

input:

CCCCTTTTAAAA
1
1 12

output:

ATCG

result:

ok single line: 'ATCG'

Test #21:

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

input:

CCCCGGGGAAAA
1
1 12

output:

AGCT

result:

ok single line: 'AGCT'

Test #22:

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

input:

CCCCGGGGTTTT
1
1 12

output:

TGCA

result:

ok single line: 'TGCA'

Test #23:

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

input:

CCCGGGTTTAAA
1
1 12

output:

ATGC

result:

ok single line: 'ATGC'

Test #24:

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

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: 4388kb

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: 4156kb

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: 3596kb

input:

ATGCGGTTTTACTGGAAGGGTATCCCACTTAGGTAATATGCATGTGAGATAACAAAAGTCAACGCATAGTTATTAATTAACGCTGGATAGAAAGCGAGAGGTACGAAATGTATGTGCTATGTGATCCTTAGCTAGTACTCCGAAGACGGTTAATTGATTCAGGTACCCTTTAGCAAAACTGACCGTAAAGGAGAGAAGGACAAGCCTGGGGCGAATCGTCCCCGTGACGGATATAGCAACATTACACGTTTATATCCGAGGTAGTATCGGCTGATACATGCTATTGATGTAGCATTTCGA...

output:

TGAC
ATGC
TACG
ACTG
GTAC
TCGA
TACG
TAGC
TACG
TACG

result:

ok 10 lines

Test #28:

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

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: 3836kb

input:

TGCGTCCCCTGGCTAAGTGATAGGATAATCTCCATATCGCGTTGTATAGGATGCACTAAGTGTACCACAACACGATGCACCTGAGCATGAAGAAGTTGAGACTGAGTTATCGCAGAGAACTCGGCCTTTCTCCAGCCCGGCGTGCGAGAGGCACGACCGCAATATTTGACCCGCTGGTAACAGAAGACTTAGCTCCAAGGTGAGAACTGCCCTGGGATTAGTCCAGGGTGATTGTGCGCCCTCCACCCGACCCGCATTTCGTCAAATGGACGTAACACATTAACATTTGGTGACGGCCAA...

output:

TCGA
TCGA
TCGA
TCGA
TGCA
TGCA
TCGA
CTGA
TACG
TCGA

result:

ok 10 lines

Test #30:

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

input:

CAACTGCAGCCCTTTAACCGAGCCCAGAGGAGGATTACAAGCTTTCGTCAGGTGCGACTCCAAACGTTACGCGGTATGGCTTTCCTAAGTCCAGTCCCCGCGTAAGCGGCAGTAATCAGTTGCGTTGGCCAACAGCCTGGCCGGCACTTCCTCTCTCTTGACATAGGGTCAAGCAGTTGGCGATTCATGTAACTTCTAGCTACCAGGCGCCTCAATCGGGAAACTCTGGAGTGACGACAGCACGTAGCTTCTTAGTATGGAACAGGATATGGAAATTGGCCAGAATTCCTGTTTACGACT...

output:

GTCA
CTAG
ATCG
CTAG
GTAC
CTAG
CGTA
CATG
CTAG
TACG

result:

ok 10 lines

Test #31:

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

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: 4156kb

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: 4484kb

input:

ACTCGACAATTAGAGTCTAATAGACCGGGACAGAGTTGTGGACTAGAGACAAATCTAAAAGGCGTGTGCGCCCAGGGTTGCCTCCAGTCAGTCCGTGTCGTACCCTAGTAGCTCTAGCCAAGAATTCATTGTTGTGGCTTCACCTCGACAAGACGCCTTCCAAGATGCGGGTGTAATAGGATCGGGCACAATCGCTTTTCGGCTTGACAATCGGATAGAGCGTTGCTAGCCGGTCTGTCTGATCGATAACTACTTCGAAAAGCCCTACCAGGCGATGGGTGGTAATTTTTTAATATTCAA...

output:

ATCG
ATCG
AGCT
AGCT
ATCG
AGTC
AGTC
CGAT
GTCA
GCAT

result:

ok 10 lines