fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. // #define int long long
  4. #define yes cout << "YES\n";
  5. #define nl cout << endl;
  6. #define no cout << "NO\n";
  7. #define all(x) x.begin(), x.end()
  8. #define allr(x) x.rbegin(), x.rend()
  9. #define pb push_back
  10. #define ppb pop_back
  11. #define mp make_pair
  12. #define ff first
  13. #define ss second
  14. #define st string
  15. #define fr(i, x, y) for (int i = x; i < y; i++)
  16. #define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  17.  
  18. // #define MAX 1e18
  19. // #define MIN -1e18
  20.  
  21. #ifndef ONLINE_JUDGE
  22. #define debug(x) cerr << setw(15) << left << #x << ": "; _print(x); cerr << endl;
  23. #define del cerr << '\n';
  24. #else
  25. #define debug(x)
  26. #define del
  27. #endif
  28.  
  29. void _print(int t) {cerr << t;}
  30. void _print(string t) {cerr << t;}
  31. void _print(char t) {cerr << t;}
  32.  
  33. template <typename T, typename V> void _print(const pair<T, V>& p) {cerr << '{'; _print(p.first); cerr << ", "; _print(p.second); cerr << '}';}
  34. template <typename T> void _print(const vector<T>& v) {cerr << '['; for (size_t i = 0; i < v.size(); ++i) {_print(v[i]); if (i != v.size() - 1) cerr << ", ";} cerr << ']';}
  35. template <typename T> void _print(const set<T>& s) {cerr << '{'; bool first = true; for (const auto& x : s) {if (!first) cerr << ", "; _print(x); first = false;} cerr << '}';}
  36. template <typename T> void _print(const multiset<T>& s) {cerr << '{'; bool first = true; for (const auto& x : s) {if (!first) cerr << ", "; _print(x); first = false;} cerr << '}';}
  37. template <typename T, typename V> void _print(const map<T, V>& m) {cerr << '{'; bool first = true; for (const auto& kv : m) {if (!first) cerr << ", "; _print(kv); first = false;} cerr << '}';}
  38.  
  39. int power(int n, int k){int result = 1;while (k > 0) {if (k & 1) {result = (result * n);}n = (n * n);k >>= 1;}return result;}
  40. int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
  41. int lcm(int a, int b) {return (a / __gcd(a, b)) * b;}
  42. bool isPrime(int n) {if (n <= 1) return false;if (n == 2) return true;if (n % 2 == 0) return false;for (int i = 3; i * i <= n; i += 2) {if (n % i == 0) return false;}return true;}
  43.  
  44.  
  45.  
  46.  
  47. void solve(){
  48. int n; cin>>n;
  49. vector<int> a(n+1), b(n+1);
  50. for(int i = 1;i<=n;++i) cin>>a[i];
  51. for(int i = 1;i<=n;++i) cin>>b[i];
  52.  
  53.  
  54. int first = b[1];
  55. int ind = -1;
  56. int second;
  57. for(int i = 1;i<=n;++i){
  58. if(b[i] != first){
  59. ind = i;
  60. second = b[i]; break;
  61. }
  62. }
  63.  
  64.  
  65. int first_ind = -1;
  66. for(int i = 1;i<=n;++i){
  67. if(a[i] == first){
  68. first_ind = i; break;
  69. }
  70. }
  71. if(first_ind == -1){
  72. cout<<"NO"; return;
  73. }
  74.  
  75.  
  76.  
  77.  
  78. bool f = 0;
  79. int second_ind = -1;
  80. for(int i = first_ind;i<=n;++i){
  81. if(a[i] == second){
  82. second_ind = i;
  83. f = 1; break;
  84. }
  85. }
  86. if(!f){
  87. cout<<"NO"; return;
  88. }
  89.  
  90.  
  91. ind--;
  92.  
  93.  
  94. if(first_ind >= ind){ // 1st er ta dan dike
  95. cout<<"YES 4"; nl
  96.  
  97.  
  98. cout<<1<<" "<<first_ind<<" "<<first_ind; nl
  99. cout<<1<<" "<<ind<<" "<<1; nl
  100.  
  101.  
  102. cout<<second_ind<<" "<<n<<" "<<second_ind; nl
  103. cout<<ind + 1<<" "<<n<<" "<<n;
  104. return;
  105. }
  106.  
  107. cout<<"YES 4"; nl
  108.  
  109.  
  110. cout<<second_ind<<" "<<n<<" "<<second_ind; nl
  111. cout<<ind + 1<<" "<<n<<" "<<n; nl
  112.  
  113.  
  114.  
  115. cout<<1<<" "<<first_ind<<" "<<first_ind; nl
  116. cout<<1<<" "<<ind<<" "<<1;
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. }
  124.  
  125.  
  126. int32_t main() {
  127. FAST
  128.  
  129.  
  130.  
  131. #ifndef ONLINE_JUDGE
  132. freopen("error.txt", "w", stderr);
  133. #endif
  134.  
  135. int t = 1;
  136. cin >> t;
  137. while (t--) {
  138. solve();
  139. cout << endl;
  140. }
  141. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
YES 4
1 1 1
1 -2 1
1 32767 1
-1 32767 32767