参考代码:
#include using namespace std; struct nodea{ int id,w; } a[100005];struct nodeb{ int id,w; }b[100005]; bool cmp1(nodea a,nodea b){ if(a.w != b.w) return a.w < b.w; else return a.id < b.id; } bool cmp2(nodeb a,nodeb b){ if(a.w != b.w) return a.w > b.w; else return a.id < b.id; } int main(){ int n1,n2; cin >> n1 >> n2; for(int i = 1; i > a[i].w, a[i].id = i; for(int i = 1; i > b[i].w, b[i].id = i; sort(a+1,a+n1+1,cmp1); sort(b+1,b+n2+1,cmp2); string s; cin >> s; int idx1 = 1,idx2 = 1; for(int i=0;i<s.length();i++){ if(s[i] == '1'){ cout << "B"; cout << b[idx1++].id << endl; } else{ cout << "A"; cout << a[idx2++].id << endl; } } cout << "E" << endl; return 0; }
0.0分
1 人评分
母牛的故事 (C语言代码)浏览:743 |
陶陶摘苹果 (C语言代码)浏览:1607 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:1118 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:643 |
WU-C语言程序设计教程(第三版)课后习题12.1 (C++代码)浏览:940 |
三角形 (C语言代码)浏览:914 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:541 |
小九九 (C语言描述,不看要求真坑爹)浏览:985 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:537 |
企业奖金发放 (C语言代码)浏览:2325 |