QOJ.ac
QOJ
QOJ is currently under a maintenance. It might be unavailable in the following a few hours.
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#815697 | #9849. Amino Acids | Brno (Bocheng Jiang, Zhenyu Wang, Taixiang Wang)# | AC ✓ | 8ms | 4064kb | C++20 | 3.1kb | 2024-12-15 16:29:47 | 2024-12-15 16:29:48 |
Judging History
answer
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define mk make_pair
#define MID int mid=(l+r)>>1;
#define ll long long
#define endl '\n'
#define siz(a) int(a.size())
int mol[]={89,132,133,121,146,147,75,149,105,119};
string name[]={"Ala","Asn","Asp","Cys","Gln","Glu","Gly","Met","Ser","Thr"};
int len[]={7,9,7,7,11,9,5,13,7,9};
vector<int>ans;
vector<vector<int>>res;
int s[110],t,n,m;
string line1=" H H O ";
string line2=" | | || ";
string litop="-N-C-C--";
string limid="-N-C-C--";
string liend="-N-C-C-O-H";
string line4=" | ";
string lispc=" ";
string st[20][20],tmp[20];
void pr(vector<int>ans){
for(int i=0;i<19;i++)tmp[i]=" ";
tmp[2]="H";
int sz=ans.size(),l=0;
for(int i=0;i<sz;i++){
tmp[0]+=line1;
tmp[1]+=line2;
if(i==0)tmp[2]+=litop;
else if(i==sz-1)tmp[2]+=liend;
else tmp[2]+=limid;
tmp[3]+=line4;
// cout<<ans[i]<<' '<<len[ans[i]]<<endl;
l=max(l,len[ans[i]]);
}
for(int i=4;i<l;i++){
for(int j=0;j<sz;j++){
tmp[i]+=st[ans[j]+1][i-4];
}
}
for(int i=0;i<l;i++){
cout<<tmp[i]<<endl;
}
cout<<endl;
}
void dfs(int n,int M){
if(M<0)return;
if(n>=2){
res.push_back(ans);
}
for(int i=1;i<=t;i++){
ans.push_back(s[i]);
dfs(n+1,M-mol[s[i]]+(n!=0)*18);
ans.pop_back();
}
}
void solveclr(){
}
void solve(){
solveclr();
st[1][0]=" H-C-H ";
st[1][1]=" | ";
st[1][2]=" H ";
for(int i=3;i<19;i++)st[1][i]=lispc;
st[2][0]=" H-C-H ";
st[2][1]=" | ";
st[2][2]=" O=C-N-H";
st[2][3]=" | ";
st[2][4]=" H ";
for(int i=5;i<19;i++)st[2][i]=lispc;
st[3][0]=" H-C-H ";
st[3][1]=" | ";
st[3][2]=" O=C-O-H";
for(int i=3;i<19;i++)st[3][i]=lispc;
st[4][0]=" H-C-S-H";
st[4][1]=" | ",
st[4][2]=" H ";
for(int i=3;i<19;i++)st[4][i]=lispc;
st[5][0]=" H-C-H ";
st[5][1]=" | ";
st[5][2]=" H-C-H ";
st[5][3]=" | ";
st[5][4]=" O=C-N-H";
st[5][5]=" | ";
st[5][6]=" H ";
for(int i=7;i<19;i++)st[5][i]=lispc;
st[6][0]=" H-C-H ";
st[6][1]=" | ";
st[6][2]=" H-C-H ";
st[6][3]=" | ";
st[6][4]=" O=C-O-H";
for(int i=5;i<19;i++)st[6][i]=lispc;
st[7][0]=" H ";
for(int i=1;i<19;i++)st[7][i]=lispc;
st[8][0]=" H-C-H ";
st[8][1]=" | ";
st[8][2]=" H-C-H ";
st[8][3]=" | ";
st[8][4]=" S ";
st[8][5]=" | ";
st[8][6]=" H-C-H ";
st[8][7]=" | ";
st[8][8]=" H ";
for(int i=9;i<19;i++)st[8][i]=lispc;
st[9][0]=" H-C-O-H";
st[9][1]=" | ";
st[9][2]=" H ";
for(int i=3;i<19;i++)st[9][i]=lispc;
st[10][0]=" H-C-O-H";
st[10][1]=" | ",
st[10][2]=" H-C-H ";
st[10][3]=" | ",
st[10][4]=" H ";
for(int i=5;i<19;i++)st[10][i]=lispc;
cin>>n>>m;
for(int i=1;i<=n;i++){
string a;cin>>a;
for(int j=0;j<10;j++){
if(a==name[j]){
s[++t]=j;
// cout<<j<<' ';
break;
}
}
}
sort(s+1,s+1+t);
dfs(0,m);
cout<<res.size()<<endl;
for(auto x:res){
pr(x);
}
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int TTT;
// cin>>TTT;
TTT=1;
while(TTT--)solve();
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
2 150 Ala Gly
output:
3 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H | H H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H H-C-H | H H H O H H O | | || | | || H-N-...
result:
ok 22 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
10 401 Cys Asp Asn Ala Glu Gly Met Ser Gln Thr
output:
4299 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | H H H H O H H O H H O | | || | | || | | || H-N-C-C---N-C-C---N-C-C-O-H | | | H-C-H H-C-H H-C-H | | | H ...
result:
ok 44518 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
5 359 Gln Asp Cys Glu Ser
output:
87 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | O=C-O-H O=C-O-H H H O H H O H H O | | || | | || | | || H-N-C-C---N-C-C---N-C-C-O-H | | | H-C-H H-C-H H-C-S-H | | | O=C-O-H ...
result:
ok 854 lines
Test #4:
score: 0
Accepted
time: 8ms
memory: 4064kb
input:
10 450 Cys Ala Gln Glu Asn Gly Ser Asp Met Thr
output:
15663 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | H H H H O H H O H H O | | || | | || | | || H-N-C-C---N-C-C---N-C-C-O-H | | | H-C-H H-C-H H-C-H | | | H ...
result:
ok 165520 lines
Test #5:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
6 358 Asn Gln Gly Cys Asp Thr
output:
299 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | O=C-N-H O=C-N-H | | H H H H O H H O H H O | | || | | || | | || H-N-C-C---N-C-C---N-C-C-O-H | | | H-C-H H-C-H H-C-S-H...
result:
ok 2960 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 4032kb
input:
10 373 Ala Asp Cys Glu Gly Met Ser Gln Asn Thr
output:
2148 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | H H H H O H H O H H O | | || | | || | | || H-N-C-C---N-C-C---N-C-C-O-H | | | H-C-H H-C-H H-C-H | | | H ...
result:
ok 21910 lines
Test #7:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
9 367 Gly Asn Gln Asp Glu Ser Cys Met Thr
output:
1056 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | O=C-N-H O=C-N-H | | H H H H O H H O H H O | | || | | || | | || H-N-C-C---N-C-C---N-C-C-O-H | | | H-C-H H-C-H H-C-H ...
result:
ok 11214 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
4 294 Ala Glu Asn Gly
output:
63 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | H H H H O H H O H H O | | || | | || | | || H-N-C-C---N-C-C---N-C-C-O-H | | | H-C-H H-C-H H-C-H | | | H ...
result:
ok 570 lines
Test #9:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
6 388 Ser Asp Gln Glu Met Thr
output:
203 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | O=C-O-H O=C-O-H H H O H H O H H O | | || | | || | | || H-N-C-C---N-C-C---N-C-C-O-H | | | H-C-H H-C-H H-C-H | | | O=C-O-H...
result:
ok 2384 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
3 388 Ser Gln Asn
output:
36 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | O=C-N-H O=C-N-H | | H H H H O H H O H H O | | || | | || | | || H-N-C-C---N-C-C---N-C-C-O-H | | | H-C-H H-C-H H-C-H ...
result:
ok 400 lines
Test #11:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
5 265 Met Glu Asn Asp Thr
output:
21 H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | O=C-N-H O=C-N-H | | H H H H O H H O | | || | | || H-N-C-C---N-C-C-O-H | | H-C-H H-C-H | | O=C-N-H O=C-O-H ...
result:
ok 232 lines
Extra Test:
score: 0
Extra Test Passed