solution
一开始想的是用质数将一半的点更改掉,WA3,然后用1e9+7开始不断增加来替代原序列结果WA2,最后想到直接找到最小值,向两边递增即可。
code
/*SiberianSquirrel*//*CuteKiloFish*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = ll(1e9 + 7);
const ll INF = ll(1e18 + 10);
//VAR
ll a[600000];
void solve() {
int o; cin >> o;
while(o --) {
int k = 0;
int n; cin >> n;
ll minn = 10000000000;
ll temp = 1000000007;
int pos = 0;
for (int i = 1; i <= n; ++ i){
cin >> a[i];
if(minn > a[i]) {
minn = a[i];
pos = i;
}
}
if (n == 1) {
cout << 0 << endl;
continue;
}
cout << n - 1 << endl;
temp = a[pos];
for(int i = pos - 1; i >= 1; -- i) {
cout << pos << ' ' << i << ' ';
a[i] = ++ temp;
cout << minn << ' ' << a[i] << endl;
}
temp = a[pos];
for(int i = pos + 1; i <= n; ++ i) {
cout << pos << ' ' << i << ' ';
a[i] = ++ temp;
cout << minn << ' ' << a[i] << endl;
}
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifdef ACM_LOCAL
freopen("input", "r", stdin);
freopen("output", "w", stdout);
signed test_index_for_debug = 1;
char acm_local_for_debug = 0;
do {
if (acm_local_for_debug == '$') exit(0);
if (test_index_for_debug > 20)
throw runtime_error("Check the stdin!!!");
auto start_clock_for_debug = clock();
solve();
auto end_clock_for_debug = clock();
cout << "Test " << test_index_for_debug << " successful" << endl;
cerr << "Test " << test_index_for_debug++ << " Run Time: "
<< double(end_clock_for_debug - start_clock_for_debug) / CLOCKS_PER_SEC << "s" << endl;
cout << "--------------------------------------------------" << endl;
} while (cin >> acm_local_for_debug && cin.putback(acm_local_for_debug));
#else
solve();
#endif
return 0;
}