#include<bits/stdc++.h> using namespace std; #define maxn 200005 struct node { int order,num; } a[maxn]; bool cmp(node a,node b) { return a.num>b.num; } int main() { string str; int n; cin>>n; for(int i=0; i<n; i++) { cin>>a[i].num; a[i].order=i+1; } stack<node>one; stack<node>two; sort(a,a+n,cmp); for(int i=0; i<n; i++) one.push(a[i]); cin>>str; for(int i=0; str[i]; i++) { if(str[i]=='0') { if(i==0) cout<<one.top().order; else cout<<" "<<one.top().order; two.push(one.top()); one.pop(); } else { if(i==0) cout<<two.top().order; else cout<<" "<<two.top().order; two.pop(); } } cout<<endl; return 0; }
B - Bus of Characters (STACK-模拟)
最新推荐文章于 2022-08-22 12:15:21 发布