Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Problem: A1. Dual (Easy Version)
- // Contest: Codeforces - Codeforces Round 889 (Div. 1)
- // URL: https://codeforces.com/problemset/problem/1854/A1
- // Memory Limit: 256 MB
- // Time Limit: 1000 ms
- //
- // Powered by CP Editor (https://cpeditor.org)
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- #ifndef __DEBUG__
- #define dbg(...) 42
- #endif
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using ll = long long;
- using pii = pair<int, int>;
- using pll = pair<ll, ll>;
- using vl = vector<ll>;
- using vi = vector<int>;
- int main(int argc, char **argv)
- {
- ll t, n;
- cin >> t;
- while (t--) {
- cin >> n;
- vl a(n);
- for (auto &x : a)
- cin >> x;
- if (n == 1) {
- cout << 0 << '\n';
- continue;
- }
- if (count_if(a.begin(), a.end(), [](ll x) { return x < 0; }) == n) {
- cout << n - 1 << '\n';
- for (ll i = n - 1; i >= 1; --i)
- cout << i << ' ' << i + 1 << '\n';
- } else if (count(a.begin(), a.end(), 0) == n) {
- cout << 0 << '\n';
- } else {
- ll one = find_if(a.begin(), a.end(), [](ll x) { return x > 0; }) - a.begin() + 1;
- cout << 5 + 2 * (n - 1) << '\n';
- for (ll i = 0; i < 5; ++i)
- cout << one << ' ' << one << '\n';
- cout << 2 << ' ' << one << '\n' << 2 << ' ' << one << '\n';
- for (ll i = 3; i <= n; ++i)
- cout << i << ' ' << i - 1 << '\n' << i << ' ' << i - 1 << '\n';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement