QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#578049#5660. Simplified Genome TranslationCelestialCoder#AC ✓1ms3784kbC++203.2kb2024-09-20 16:11:572024-09-20 16:11:57

Judging History

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

  • [2024-09-20 16:11:57]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3784kb
  • [2024-09-20 16:11:57]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef SHARAELONG
#include "../../cpp-header/debug.hpp"
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

vector<pair<string, int>> codon;

void solve() {
    string r;
    cin >> r;
    int n = r.size();
    string ans;
    bool stop = false;
    for (int i=0; i<n; i+=3) {
        string s = r.substr(i, 3);
        for (int j=0; j<codon.size(); ++j) {
            if (codon[j].first == s) {
                if (codon[j].second != -1) ans += codon[j].second;
                else {
                    stop = true;
                }
                break;
            }
        }
        if (stop) break;
    }
    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    codon.push_back({ "UUU", 'F' });
    codon.push_back({ "UUC", 'F' });
    codon.push_back({ "UUA", 'L' });
    codon.push_back({ "UUG", 'L' });
    codon.push_back({ "CUU", 'L' });
    codon.push_back({ "CUC", 'L' });
    codon.push_back({ "CUA", 'L' });
    codon.push_back({ "CUG", 'L' });
    codon.push_back({ "AUU", 'I' });
    codon.push_back({ "AUC", 'I' });
    codon.push_back({ "AUA", 'I' });
    codon.push_back({ "AUG", 'M' });
    codon.push_back({ "GUU", 'V' });
    codon.push_back({ "GUC", 'V' });
    codon.push_back({ "GUA", 'V' });
    codon.push_back({ "GUG", 'V' });
    codon.push_back({ "UCU", 'S' });
    codon.push_back({ "UCC", 'S' });
    codon.push_back({ "UCA", 'S' });
    codon.push_back({ "UCG", 'S' });
    codon.push_back({ "AGU", 'S' });
    codon.push_back({ "AGC", 'S' });
    codon.push_back({ "CCU", 'P' });
    codon.push_back({ "CCC", 'P' });
    codon.push_back({ "CCA", 'P' });
    codon.push_back({ "CCG", 'P' });
    codon.push_back({ "ACU", 'T' });
    codon.push_back({ "ACC", 'T' });
    codon.push_back({ "ACA", 'T' });
    codon.push_back({ "ACG", 'T' });
    codon.push_back({ "GCU", 'A' });
    codon.push_back({ "GCC", 'A' });
    codon.push_back({ "GCA", 'A' });
    codon.push_back({ "GCG", 'A' });
    codon.push_back({ "UAU", 'Y' });
    codon.push_back({ "UAC", 'Y' });
    codon.push_back({ "CAU", 'H' });
    codon.push_back({ "CAC", 'H' });
    codon.push_back({ "CAA", 'Q' });
    codon.push_back({ "CAG", 'Q' });
    codon.push_back({ "AAU", 'N' });
    codon.push_back({ "AAC", 'N' });
    codon.push_back({ "AAA", 'K' });
    codon.push_back({ "AAG", 'K' });
    codon.push_back({ "GAU", 'D' });
    codon.push_back({ "GAC", 'D' });
    codon.push_back({ "GAA", 'E' });
    codon.push_back({ "GAG", 'E' });
    codon.push_back({ "UGU", 'C' });
    codon.push_back({ "UGC", 'C' });
    codon.push_back({ "UGG", 'W' });
    codon.push_back({ "CGU", 'R' });
    codon.push_back({ "CGC", 'R' });
    codon.push_back({ "CGA", 'R' });
    codon.push_back({ "CGG", 'R' });
    codon.push_back({ "AGA", 'R' });
    codon.push_back({ "AGG", 'R' });
    codon.push_back({ "GGU", 'G' });
    codon.push_back({ "GGC", 'G' });
    codon.push_back({ "GGA", 'G' });
    codon.push_back({ "GGG", 'G' });
    codon.push_back({ "UAA", -1 });
    codon.push_back({ "UAG", -1 });
    codon.push_back({ "UGA", -1 });
    
    int cases;
    cin >> cases;
    while (cases--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
UUUUAACACUUUAUCACUUAACACCAC
CAAAAUAUGAAAAAU
AUGUACUUUGCGUUUCACUAA
UUGCACUACUAC
UACGUGGGUAUC

output:

F
QNMKN
MYFAFH
LHYY
YVGI

result:

ok 5 lines

Test #2:

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

input:

50
GGUCAGAGGGAGGGCCUAUUGAUACGUAGUGGACUAUCAUGUUCGUGAGCAGCAUGCAGAUUACCCGUUCGGCGAGGGAGAGCCCGCUCCGAAAUGUUUAGGGAGAUAGCGGGCCACAUAGUCGCUUGAGUGCAUACUGCGUACUUUAUGUACAAGUCCCGU
AAUGGAUCACUCCUCUAUCAUUUCACUAGGUGUGACACAUGAUAUACUAACGUUCUGAAUUGGCAGUGGGGUAUGAGGCACUGAUUGGUCAUGGGACAGACUUGAGAGGAGUUGUCCUUGCUAAGCCCCGUCCC...

output:

GQREGLLIRSGLSCS
NGSLLYHFTRCDT
DASYKADEGLMFVLKDTGDYGSDYWQK
SRKVLVDRISEPLVVAYLEGTDVDGANIGSKFDGANSSAWT
FACST
LTNARTSFYALRFKDACKYTCKSLFELFSNRGQFS
II
VLLRAARISCTFIHCRCSRRGFGPLSPCPPRPLAGVGSMIYNSCYIY
TRKLSFS
ESDQC
QNGIPKKAC
PHTRRTLPPSV
GI
ATSNVCTSFHGAGASGRNVCIRGRDRPL
AF
NPFQVSRSLQPRS
IHPGYLRTGGGFRSILSVTRDG...

result:

ok 50 lines

Test #3:

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

input:

50
GGUCAGAGGGAGGGCCUAUUGAUACGUAGUGGACUAUCAUGUUCGUGAGCAGCAUGCAGAUUACCCGUUCGGCGAGGGAGAGCCCGCUCCGAAAUGUUUAGGGAGAUAGCGGGCCACAUAGUCGCUUGAGUGCAUACUGCGUACUUUAUGUACAAGUCCCGU
AAUGGAUCACUCCUCUAUCAUUUCACUAGGUGUGACACAUGAUAUACUAACGUUCUGAAUUGGCAGUGGGGUAUGAGGCACUGAUUGGUCAUGGGACAGACUUGAGAGGAGUUGUCCUUGCUAAGCCCCGUCCC...

output:

GQREGLLIRSGLSCS
NGSLLYHFTRCDT
DASYKADEGLMFVLKDTGDYGSDYWQK
SRKVLVDRISEPLVVAYLEGTDVDGANIGSKFDGANSSAWT
FACST
LTNARTSFYALRFKDACKYTCKSLFELFSNRGQFS
II
VLLRAARISCTFIHCRCSRRGFGPLSPCPPRPLAGVGSMIYNSCYIY
TRKLSFS
ESDQC
QNGIPKKAC
PHTRRTLPPSV
GI
ATSNVCTSFHGAGASGRNVCIRGRDRPL
AF
NPFQVSRSLQPRS
IHPGYLRTGGGFRSILSVTRDG...

result:

ok 50 lines