Lexicographical Comparison Compare given two sequence A={a0,a1,…,an−1} and B={b0,b1,…,bm−1 lexicographically.
输入
The input is given in the following format. n a0 a1,…,an−1 m b0 b1,…,bm−1 The number of elements in A and its elements ai are given in the first and second lines respectively. The number of elements in B and its elements bi are given in the third and fourth lines respectively. All input are given in integers.
输出
Print 1 B is greater than A, otherwise 0.
样例输入
3
1 2 3
2
2 4
样例输出
1
题解(代码流程)
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, m;
cin >> n;
vector<int> A(n);
for (int i = 0; i < n; i++)cin >> A[i];
cin >> m;
vector<int> B(m);
for (int i = 0; i < m; i++)cin >> B[i];
cout << (A < B) << endl;//直接字典序比较
return 0;
}