link
题意之后有空补 先贴上代码
思路// Decline is inevitable, // Romance will last forever. #includeusing namespace std; #define RE0 return 0 #define mp make_pair #define pii pair #define pb push_back #define fi first #define se second #define ll long long #define LL long long //#define int long long #define endl 'n' #define ld long double #define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++) #define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--) const int maxn = 1e5 + 10; const int INF = 0x3f3f3f3f; const int dx[] = {0, 0, -1, 1}; //{0, 0, 1, 1, 1,-1,-1,-1} const int dy[] = {1, -1, 0, 0}; //{1,-1, 1, 0,-1, 1, 0,-1} const int P = 998244353; //998244353 int n; struct node { int a, b, id; //bool operator < (const node &x) const { // return a < x.a; //} }p[maxn]; bool cmp(node x, node y) { return x.a < y.a; } bool ans[maxn]; void solve() { cin >> n; For(i, 1, n) ans[i] = false; int maxa = 0; int minb = 0x7f7f7f7f; int maxb = 0; int mid = 0; For(i, 1, n) { p[i].id = i; cin >> p[i].a; } For(i, 1, n) { cin >> p[i].b; } sort(p + 1, p + n + 1, cmp); for(int i = 1; i <= n; i++) { if(maxb < p[i].b) { maxb = p[i].b; // mid = p[i].id; mid = i; } } for(int i = n; i >= mid; i--) { minb = min(minb, p[i].b); ans[p[i].id] = 1; } int tmp = mid; for(int i = tmp - 1; i >= 1; i--) { if(p[i].b > minb) { for(int j = mid; j >= i; j--) { ans[p[j].id] = 1; minb = min(minb, p[j].b); } mid = i - 1; } } for(int i = 1; i <= n; i++) { cout << ans[i]; } cout << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); // int T; scanf("%d", &T); while(T--) // freopen("1.txt","r",stdin); // freopen("2.txt","w",stdout); int T; cin >> T; while(T--) solve(); RE0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)