QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524286#5660. Simplified Genome Translationchen_han#AC ✓1ms3852kbC++141.8kb2024-08-19 15:03:592024-08-19 15:04:01

Judging History

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

  • [2024-08-19 15:04:01]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3852kb
  • [2024-08-19 15:03:59]
  • 提交

answer

#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0)
#define ll long long
#define pcc pair<char,char>
using namespace std;

vector<pcc> v[4][4];
string s,ss;
int n,out;
string str=R"(
F UUU UUC
L UUA UUG CUU CUC CUA CUG
I AUU AUC AUA
M AUG
V GUU GUC GUA GUG
S UCU UCC UCA UCG AGU AGC
P CCU CCC CCA CCG
T ACU ACC ACA ACG
A GCU GCC GCA GCG
Y UAU UAC
H CAU CAC
Q CAA CAG
N AAU AAC
K AAA AAG
D GAU GAC
E GAA GAG
C UGU UGC
W UGG
R CGU CGC CGA CGG AGA AGG
G GGU GGC GGA GGG
! UAA UAG UGA)";

inline int fac(char c){
    switch(c){
        case 'A': return 0;
        case 'C': return 1;
        case 'G': return 2;
        case 'U': return 3;
        default: return -1;
    }
}

void init(){
    istringstream ss(str);
    string seg;
    char ch;
    while(ss>>seg){
        if(seg.size()==1){
            ch=seg[0];
        }
        else{
            v[fac(seg[0])][fac(seg[1])].push_back({seg[2],ch});
        }
    }
}

int main(){
    ios;
    init();
    cin>>n;
    for(int i=0;i<n;i++){
        out=0;
        cin>>s;
        ss.clear();
        for(auto it=s.begin();it!=s.end();it++){
            if(out) break;
            ss+=*it;
            if(ss.size()==3){
                int a=fac(ss[0]);
                int b=fac(ss[1]);
                for(auto &i: v[a][b]){
                    if(i.first==ss[2]){
                        if(i.second!='!'){
                            cout<<i.second;
                        }
                        else{
                            out=1;
                            break;
                        }
                    }
                }
                ss.clear();
            }
        }
        cout<<endl;
    }



    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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