Advertisement
pb_jiang

CF1854A1

Jun 14th, 2024
699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1. // Problem: A1. Dual (Easy Version)
  2. // Contest: Codeforces - Codeforces Round 889 (Div. 1)
  3. // URL: https://codeforces.com/problemset/problem/1854/A1
  4. // Memory Limit: 256 MB
  5. // Time Limit: 1000 ms
  6. //
  7. // Powered by CP Editor (https://cpeditor.org)
  8.  
  9. #include <assert.h>
  10. #include <bits/stdc++.h>
  11. using namespace std;
  12. #ifndef __DEBUG__
  13. #define dbg(...) 42
  14. #endif
  15. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  16.  
  17. using ll = long long;
  18. using pii = pair<int, int>;
  19. using pll = pair<ll, ll>;
  20. using vl = vector<ll>;
  21. using vi = vector<int>;
  22.  
  23. int main(int argc, char **argv)
  24. {
  25.     ll t, n;
  26.     cin >> t;
  27.     while (t--) {
  28.         cin >> n;
  29.         vl a(n);
  30.         for (auto &x : a)
  31.             cin >> x;
  32.         if (n == 1) {
  33.             cout << 0 << '\n';
  34.             continue;
  35.         }
  36.         if (count_if(a.begin(), a.end(), [](ll x) { return x < 0; }) == n) {
  37.             cout << n - 1 << '\n';
  38.             for (ll i = n - 1; i >= 1; --i)
  39.                 cout << i << ' ' << i + 1 << '\n';
  40.         } else if (count(a.begin(), a.end(), 0) == n) {
  41.             cout << 0 << '\n';
  42.         } else {
  43.             ll one = find_if(a.begin(), a.end(), [](ll x) { return x > 0; }) - a.begin() + 1;
  44.             cout << 5 + 2 * (n - 1) << '\n';
  45.             for (ll i = 0; i < 5; ++i)
  46.                 cout << one << ' ' << one << '\n';
  47.             cout << 2 << ' ' << one << '\n' << 2 << ' ' << one << '\n';
  48.             for (ll i = 3; i <= n; ++i)
  49.                 cout << i << ' ' << i - 1 << '\n' << i << ' ' << i - 1 << '\n';
  50.         }
  51.     }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement